We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6557151 commit 9a3167eCopy full SHA for 9a3167e
lib/line-index/src/lib.rs
@@ -363,7 +363,10 @@ fn analyze_source_file_generic(
363
let c = src[i..].chars().next().unwrap();
364
char_len = c.len_utf8();
365
366
- let pos = TextSize::from(i as u32) + output_offset;
+ // The last element of `lines` represents the offset of the start of
367
+ // current line. To get the offset inside the line, we subtract it.
368
+ let pos = TextSize::from(i as u32) + output_offset
369
+ - lines.last().unwrap_or(&TextSize::default());
370
371
if char_len > 1 {
372
assert!((2..=4).contains(&char_len));
0 commit comments