From ad6cc41261a72517e44fad99269c888c4310f796 Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:07:07 -0300 Subject: [PATCH] fix decorator lexing with wrong offsets --- crates/typst-syntax/src/lexer.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/typst-syntax/src/lexer.rs b/crates/typst-syntax/src/lexer.rs index 05573b2dd..e08b4501b 100644 --- a/crates/typst-syntax/src/lexer.rs +++ b/crates/typst-syntax/src/lexer.rs @@ -199,7 +199,7 @@ impl Lexer<'_> { /// Decorators. impl Lexer<'_> { fn decorator(&mut self) -> SyntaxKind { - let start = self.s.cursor() - 1; + let start = self.s.cursor() - 2; self.decorator.clear(); @@ -227,8 +227,11 @@ impl Lexer<'_> { self.decorator.push((token, end)); } + // The saved tokens will be removed in reverse. + self.decorator.reverse(); + // Already collected all we need from the decorator. - self.s.jump(start + 1); + self.s.jump(start + 2); SyntaxKind::Decorator }