Bugfix - parse error for invalid leading whitespace. (#2703)
This commit is contained in:
parent
b989e45927
commit
fba24969b6
1 changed files with 2 additions and 1 deletions
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue