You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The highlighter mistakingly highlights the 9 line number. The span of the expression does not actually begin on the 9th line. This might be a mistake within the lexing implementation or a miscalculation within the report offset to (col, row) calculation. It's clear that the line of the span is for some reason being recorded as the end of line 9 where there is a \n character at the end.
Further investigation yielded that the actual span of expression (as printed from the raw source is):
Ideally, the report should not highlight the line number 9, like so:
This could be fixed by changing offset_col_row by not counting the \n in the case of the initial span offset, an implementation could be:
pub(crate)fnoffset_col_row(offset:usize,source:&str,non_inclusive:bool) -> (/* col: */usize,/* row: */usize){let source_lines = source.split('\n');letmut bytes_skipped = 0;letmut total_lines:usize = 0;letmut last_line_len = 0;letmut line_index = None;for(line_idx, line)in source_lines.enumerate(){// One byte for the newlinelet skip_width = line.len() + 1;// Here, we don't want an inclusive range because we don't want to get the last byte because// that will always point let range = if non_inclusive {
bytes_skipped..bytes_skipped + skip_width
}else{
bytes_skipped..bytes_skipped + skip_width + 1};if range.contains(&offset){
line_index = Some((offset - bytes_skipped, line_idx));break;}
bytes_skipped += skip_width;
total_lines += 1;
last_line_len = line.len();}
line_index.unwrap_or((
last_line_len.saturating_sub(1),
total_lines.saturating_sub(1),))}
The text was updated successfully, but these errors were encountered:
In the following error report:
The highlighter mistakingly highlights the
9
line number. The span of the expression does not actually begin on the 9th line. This might be a mistake within the lexing implementation or a miscalculation within the report offset to(col, row)
calculation. It's clear that the line of the span is for some reason being recorded as the end of line 9 where there is a\n
character at the end.Further investigation yielded that the actual span of expression (as printed from the raw source is):
Ideally, the report should not highlight the line number 9, like so:
This could be fixed by changing
offset_col_row
by not counting the\n
in the case of the initial span offset, an implementation could be:The text was updated successfully, but these errors were encountered: