Skip to content

Commit

Permalink
fix: another LC-bug, it does not handle backward case correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
KisaragiEffective committed Oct 22, 2023
1 parent 3f4664b commit cc336a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions package/origlang-compiler/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,12 @@ impl Lexer<'_> {
self.set_line(NonZeroUsize::new(new_line).expect("overflow"));
self.set_column(NonZeroUsize::new(new_col).expect("overflow"));
} else {
// THIS BRANCH IS IMPORTANT!!! OTHERWISE, RESET OPERATION WILL NOT WORK!!!
// back
let new_line = current_line - src[new..old].bytes().filter(|x| *x == b'\n').count();
let new_col = src[new..old].find('\n').map_or_else(|| {
let mut c = self.column.get().get();
c += old - new;
let mut c = self.column().get();
c -= old - new;

c
}, |new_relative| {
Expand Down
3 changes: 2 additions & 1 deletion package/origlang-compiler/src/lexer/token.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::num::NonZeroUsize;
use origlang_ast::{Comment, Identifier};
use crate::chars::boundary::Utf8CharBoundaryStartByte;
use crate::lexer::Lexer;
Expand All @@ -16,7 +17,7 @@ impl TemporalLexerUnwindToken {
}

pub fn reset(self, lexer: &Lexer) {
lexer.source_bytes_nth.set(self.unwind_index);
lexer.set_current_index(self.unwind_index).expect("Error during reset");
}
}

Expand Down

0 comments on commit cc336a8

Please sign in to comment.