Fix extra bracket in template literal syntax highlighting (#17327) #21187
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where the JavaScript syntax highlighter was incorrectly adding an extra closing bracket (
}
) when highlighting template literal interpolations containingJSON.stringify()
calls in colored terminal output.Problem
When running code like this with colors enabled:
The error output would show an extra
}
character afterJSON.stringify(
, causing malformed syntax highlighting in the error display.Root Cause
The bug was in the template literal parsing code in
src/fmt.zig
where it would always write a closing brace after processing template literal interpolation, even when a closing brace was already found and consumed from the input.Before (buggy):
After (fixed):
Solution
}
character when it's actually found in the inputTest plan
test/regression/issue/17327.test.ts
FORCE_COLOR=1
andNO_COLOR=1
modes🤖 Generated with Claude Code