Skip to content

Commit

Permalink
Fixing offset_to_line
Browse files Browse the repository at this point in the history
My memory did not match the docs of how lines() worked.
  • Loading branch information
ecton committed Apr 8, 2024
1 parent 10f1d1f commit c9c6147
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl TrackedSource {
#[must_use]
pub fn offset_to_line(&self, mut offset: usize) -> (usize, usize) {
let mut line_no = 1;
for line in self.source.lines() {
for line in self.source.split_inclusive('\n') {
if offset < line.len() {
break;
}
Expand Down

0 comments on commit c9c6147

Please sign in to comment.