Skip to content

Fix hang on block comment after an expression in JavaScript - #4091

Merged
keith-hall merged 2 commits into
sharkdp:masterfrom
NavpreetSSidhu:fix-js-block-comment-hang
Oct 20, 2026
Merged

keith-hall merged 2 commits into
sharkdp:masterfrom
NavpreetSSidhu:fix-js-block-comment-hang

Conversation

@NavpreetSSidhu

Copy link
Copy Markdown
Contributor

Closes #4080

printf 'a /*\n' | bat -l JavaScript (or a Svelte file with {a /* x */}) never returns. In the bundled JavaScript syntax, line_continuation_lookahead treats the / of /* as a division operator, so the parser keeps switching between two zero-width sets and never moves forward (trishume/syntect#709).

This adds a hunk to the existing JavaScript.sublime-syntax.patch so / only counts as a continuation when it isn't followed by *. The fix is the one @aozmekik worked out in the issue; thanks for the investigation.

Testing:

  • Added tests/syntax-tests/source/Svelte/comment_after_expression.svelte. A build without the patch hangs on it; with the patch it finishes immediately.
  • regression_test.sh: no changes in any existing highlighted output.
  • cargo test --locked passes.

@keith-hall keith-hall left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@keith-hall
keith-hall merged commit 2fd71ad into sharkdp:master Oct 20, 2026
24 checks passed
cindykrafft pushed a commit to cindykrafft/bat that referenced this pull request Oct 20, 2026
Resolve the CHANGELOG conflict by keeping the new sharkdp#4091 entry along
with the filled-in sharkdp#4076 and sharkdp#4084 entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bundled Svelte grammar has cyclical includes — syntect consumers spin forever

2 participants