Repository navigation
Handle line breaks in bash highlighting - #1217
Merged
amadeus merged 3 commits intoOct 23, 2026
Merged
Conversation
|
@pifantastic is attempting to deploy a commit to the Pierre Computer Company Team on Vercel. A member of the Team first needs to authorize it. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
amadeus
reviewed
Oct 23, 2026
amadeus
left a comment
Member
There was a problem hiding this comment.
One regression found; details inline.
A bare backslash fell through to the catch-all branch, so the line break after it reset the lexer to command position and the first word of every continued line was highlighted as a command name. An unquoted `\` before LF or CRLF now joins the next line: it is emitted as punctuation.special, the break is consumed as a gap, and $cmd carries over. A `#` heading the joined line still opens a comment. Before any other byte the `\` is a string.escape. Command position is computed before the stream checkpoint so streamed and live chunks restore it.
- `\rm` bypasses an alias and still runs `rm`: a `\` before a letter now starts a word instead of escaping one byte, so the word stays whole and takes command highlighting. `\if` misses the keyword table, and `\VAR=x` is not an assignment. - A `\` as the last byte of the range reads as a line join, matching the same `\` before a line break. - `a\` + `#b` joins into the word `a#b`, so a `#` heading a joined line only comments when a blank or command position came before the `\`. - Correct the comment on a join with a pending heredoc: bash finds the body after the joined line, but the lexer still starts it one line early. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A second `\` join cleared $joined and recomputed it from the blank before that `\`, which a `\` heading its own line never has. A `#` after the run then lexed as a word, and an apostrophe in it opened a string that swallowed the rest of the input. $joined now holds through a run of joins and clears at any other token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pifantastic
force-pushed
the
fix/bash-line-continuation
branch
from
October 23, 2026 14:25
f4639d4 to
bf59974
Compare
amadeus
approved these changes
Oct 23, 2026
Member
|
Thanks for submitting the PR and being responsive to the feedback! |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
I was playing around with migrating https://increase.com/documentation/api/overview from shiki to hightlights. I noticed our bash examples were a little off:
shiki:

highlights:

I had Opus 5.5 take a look and it uncovered the issue:
In the bash lexer, an unquoted
\before a line break fell through to thecatch-all branch, which emitted a single byte. The line break then landed in
the next whitespace gap, and the gap handler reset the lexer to command
position. So the first word of every continued line was highlighted as a
command name, e.g.
--rmandubuntuin:A continued line starting with a word like
doneeven got a keyword color.Changes in
packages/highlights/src/langs/bash.wat:\directly before LF or CRLF is emitted aspunctuation.specialand thebreak is consumed as a gap, so
$cmdcarries over to the joined line. Thismatches how the Dockerfile and Makefile lexers emit their line joins.
\before any other byte is astring.escape, so\$HOMEno longerhighlights
$HOMEas a variable.#heading a joined line still opens a comment, tracked by a new$joinedlocal that clears at the next token or real line break.and live-edited chunks restore the position the previous line ended in.
Without this the line-by-line streaming path reintroduced the bug at every
chunk boundary.
the heredoc body.
packages/highlights/package.jsonhas the regenerated wasm size inmeta.Motivation & Context
Any multi-line bash command using
\continuations rendered wrong: eachcontinued line's first argument took the command color, and some arguments
took keyword colors. Line continuations are common in shell snippets in docs,
so this showed up in ordinary usage.
Type of changes
first discussed with the dev team and they should be aware that this PR is
being opened
You must have first discussed with the dev team and they should be aware
that this PR is being opened
Checklist
contributing guidelines
moon run root:lint)moon run root:format)moonx highlights:test, 2028 tests)Added
bash: a backslash line join keeps the command openinpackages/highlights/test/bash_test.ts. It covers multi-line joins, CRLF, anassignment prefix before the join, a comment heading a joined line, a blank
line ending the command, and
\$escapes. Each case also asserts whole-inputand line-fed streaming parity via
assertLineFedParity.How was AI used in generating this PR
The fix in
bash.watand the regression test werewritten by Claude Code (Claude Opus 5.5) under my direction. I reviewed the
diff and ran the verification baseline locally (format, lint, typecheck, and
the full highlights suite).
Related issues