From e4f5385e35e69d4abd5df2cfbe5ea656a8423cf8 Mon Sep 17 00:00:00 2001 From: claude Date: Mon, 8 Jun 2026 06:54:56 +0000 Subject: [PATCH] fix(typst): fix zero-length token error for LineCommentContent LineCommentContent { ![\n]* } matches the empty string, which Lezer rejects as a zero-length token (infinite-loop risk). Change to ![\n]+ and mark it optional in the LineComment rule so empty // comments parse. Co-Authored-By: Claude Sonnet 4.6 --- .../js/features/source-editor/lezer-typst/typst.grammar | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/features/source-editor/lezer-typst/typst.grammar b/services/web/frontend/js/features/source-editor/lezer-typst/typst.grammar index 68c9db2ec6..142c822282 100644 --- a/services/web/frontend/js/features/source-editor/lezer-typst/typst.grammar +++ b/services/web/frontend/js/features/source-editor/lezer-typst/typst.grammar @@ -38,7 +38,7 @@ Heading { HeadingMark HeadingTitle? } // External tokens are context-isolated by the LR state machine — no merging. // ── Comments ────────────────────────────────────────────────────────────── -LineComment { "//" LineCommentContent } +LineComment { "//" LineCommentContent? } // BlockCommentBody is external so it can track nesting depth — // Typst supports /* /* nested */ */ block comments. BlockComment { "/*" BlockCommentBody? "*/" } @@ -182,7 +182,7 @@ Escape { "\\" EscapeChar } } // Comment content — everything to end of line. - LineCommentContent { ![\n]* } + LineCommentContent { ![\n]+ } // Math content — everything between the $ delimiters (no crossing newlines). MathContent { ![$\n]+ }