From 54b1f9c6af3aab74d9055932160b72af75910448 Mon Sep 17 00:00:00 2001 From: Navpreet Sidhu Date: Tue, 20 Oct 2026 21:31:39 +0530 Subject: [PATCH 1/2] Fix hang on block comment after an expression in JavaScript --- CHANGELOG.md | 1 + assets/patches/JavaScript.sublime-syntax.patch | 10 ++++++++++ .../highlighted/Svelte/comment_after_expression.svelte | 5 +++++ .../source/Svelte/comment_after_expression.svelte | 5 +++++ 4 files changed, 21 insertions(+) create mode 100644 tests/syntax-tests/highlighted/Svelte/comment_after_expression.svelte create mode 100644 tests/syntax-tests/source/Svelte/comment_after_expression.svelte diff --git a/CHANGELOG.md b/CHANGELOG.md index d572aea1..ac687c9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - Syntax highlighting for Python files using uv as script runner in shebang #3689 (@janlarres) ## Bugfixes +- Fix `bat` hanging forever on JavaScript (and Svelte) code where an expression is followed by a block comment, e.g. `a /* x */`. Closes #4080, see #XXXX (@NavpreetSSidhu) - Fix the first line of UTF-16BE input swallowing the second line, which broke line numbers, `--line-range` and highlighting, see #XXXX (@cindykrafft) - Exit quietly with status 0 instead of panicking when stdout is closed early (broken pipe) on auxiliary output paths such as `--completion`, `--config-file`, `--diagnostic`, `--generate-config-file`, `--set-terminal-title` and `cache --build`/`--clear`, matching the main output path since #232, closes #4034, see #4035 (@Mathjk) - Track strikethrough (SGR 9 / 29) in the ANSI style tracker so it is re-emitted like bold, dim, italic, and underline, and is no longer dropped after the first highlighted token when displaying ANSI input with syntax highlighting, see #4015 (@mikehasa) diff --git a/assets/patches/JavaScript.sublime-syntax.patch b/assets/patches/JavaScript.sublime-syntax.patch index 9ab89d1d..8f12bac7 100644 --- a/assets/patches/JavaScript.sublime-syntax.patch +++ b/assets/patches/JavaScript.sublime-syntax.patch @@ -12,3 +12,13 @@ index 05a4fed6..78a7bf55 100644 scope: source.js variables: bin_digit: '[01_]' +@@ -93,7 +93,8 @@ variables: + (?! \+\+ | -- ) + (?= + != | +- [-+*/%><=&|^\[(;,.:?] | ++ [-+*%><=&|^\[(;,.:?] | ++ /(?!\*) | + (?:in|instanceof){{identifier_break}} + ) + )) diff --git a/tests/syntax-tests/highlighted/Svelte/comment_after_expression.svelte b/tests/syntax-tests/highlighted/Svelte/comment_after_expression.svelte new file mode 100644 index 00000000..1c5db65b --- /dev/null +++ b/tests/syntax-tests/highlighted/Svelte/comment_after_expression.svelte @@ -0,0 +1,5 @@ +{a + /* comment */ +} + +{a /* comment */} diff --git a/tests/syntax-tests/source/Svelte/comment_after_expression.svelte b/tests/syntax-tests/source/Svelte/comment_after_expression.svelte new file mode 100644 index 00000000..35be16d7 --- /dev/null +++ b/tests/syntax-tests/source/Svelte/comment_after_expression.svelte @@ -0,0 +1,5 @@ +{a + /* comment */ +} + +{a /* comment */} From 49d9ac1d6e8e8deb2770c50231c9b42c1074a871 Mon Sep 17 00:00:00 2001 From: Navpreet Sidhu Date: Tue, 20 Oct 2026 21:40:03 +0530 Subject: [PATCH 2/2] changelog: reference PR #4091 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac687c9e..6845cb2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ - Syntax highlighting for Python files using uv as script runner in shebang #3689 (@janlarres) ## Bugfixes -- Fix `bat` hanging forever on JavaScript (and Svelte) code where an expression is followed by a block comment, e.g. `a /* x */`. Closes #4080, see #XXXX (@NavpreetSSidhu) +- Fix `bat` hanging forever on JavaScript (and Svelte) code where an expression is followed by a block comment, e.g. `a /* x */`. Closes #4080, see #4091 (@NavpreetSSidhu) - Fix the first line of UTF-16BE input swallowing the second line, which broke line numbers, `--line-range` and highlighting, see #XXXX (@cindykrafft) - Exit quietly with status 0 instead of panicking when stdout is closed early (broken pipe) on auxiliary output paths such as `--completion`, `--config-file`, `--diagnostic`, `--generate-config-file`, `--set-terminal-title` and `cache --build`/`--clear`, matching the main output path since #232, closes #4034, see #4035 (@Mathjk) - Track strikethrough (SGR 9 / 29) in the ANSI style tracker so it is re-emitted like bold, dim, italic, and underline, and is no longer dropped after the first highlighted token when displaying ANSI input with syntax highlighting, see #4015 (@mikehasa)