Bugfix - parse error for invalid leading whitespace. (#2703)

This commit is contained in:
Finn Bear 2023-09-22 12:43:20 -07:00 committed by GitHub
parent b989e45927
commit fba24969b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -73,7 +73,8 @@ impl Snippet {
fn truncate_line(mut line: &str, around_offset: usize) -> (&str, Truncation, usize) { fn truncate_line(mut line: &str, around_offset: usize) -> (&str, Truncation, usize) {
let full_line_length = line.chars().count(); let full_line_length = line.chars().count();
line = line.trim_start(); line = line.trim_start();
let mut offset = around_offset - (full_line_length - line.chars().count()); // Saturate in case the error ocurred in invalid leading whitespace.
let mut offset = around_offset.saturating_sub(full_line_length - line.chars().count());
line = line.trim_end(); line = line.trim_end();
let mut truncation = Truncation::None; let mut truncation = Truncation::None;