Skip to content

fix: correct bracket highlighting for multiline input MONGOSH-3699 - #26

Merged
LuciaHarcekova merged 7 commits into
mainfrom
fix/multiline-bracket-highlighting
Nov 25, 2026
Merged

LuciaHarcekova merged 7 commits into
mainfrom
fix/multiline-bracket-highlighting

Conversation

@LuciaHarcekova

Copy link
Copy Markdown
Contributor

Summary

  • Translate bracket-match offsets for Node.js 24+ multiline readline refresh chunks.
  • Highlight matching brackets directly on continuation lines and drop invalid highlights safely.
  • Add focused tests for first-line and continuation-line multiline rendering.

Testing

  • npm test — 10 passing
  • npm run lint — passing

Refs mongodb-js/mongosh#2926

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@LuciaHarcekova LuciaHarcekova changed the title fix: correct bracket highlighting for multiline input fix: correct bracket highlighting for multiline input MONGOSH-3699 Nov 23, 2026
@kmruiz

kmruiz commented Nov 23, 2026

Copy link
Copy Markdown

What I would suggest is to use the JIRA reproduction as a test too, so we ensure that the expected use case is fixed.

Comment thread test/index.spec.js Resolved
LuciaHarcekova and others added 4 commits November 23, 2026 18:11
…ests with a real _refreshLine() test using Node’s multiline state, and added the MONGOSH-3699 expression through the actual input path.
…ests with a real _refreshLine() test using Node’s multiline state, and added the MONGOSH-3699 expression through the actual input path.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@addaleax addaleax left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The logic here is quite hard to follow, but looks correct – some comments would help.

That being said, does this actually resolve the ticket? The bug that this is referencing also happens without multiline inputs.

… share the existing colorization and bracket-marking logic for those chunks, and strengthened. Added doc
@LuciaHarcekova

LuciaHarcekova commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

I’ve added comments clarifying the logic, including the Node.js 26.x behavior.

To test this branch, check it out, with either Node.js 24 or 26. You can switch versions and run the tests with:

nvm install 24
nvm use 24
npm test

nvm install 26
nvm use 26
npm test

Runs

Run Result
npm test on Node 24 15 passing
npm test on Node 26.13.1 15 passing
npm run check (depcheck + lint) Clean
node example.js Run on Node 24 and 26
Screenshot 2026-11-24 at 11 29 13 Screenshot 2026-11-24 at 11 29 48 Screenshot 2026-11-24 at 11 32 38 Screenshot 2026-11-24 at 11 34 34

Comment thread lib/pretty-repl.js Resolved
Comment thread lib/pretty-repl.js Resolved
@LuciaHarcekova
LuciaHarcekova force-pushed the fix/multiline-bracket-highlighting branch from bb59145 to f1fa460 Compare November 24, 2026 16:21
The method was defined as $_writeToOutputChunk, so every call site hit
"this._writeToOutputChunk is not a function" and any line refresh threw.
@LuciaHarcekova
LuciaHarcekova merged commit 51db392 into main Nov 25, 2026
10 checks passed
@LuciaHarcekova
LuciaHarcekova deleted the fix/multiline-bracket-highlighting branch November 25, 2026 11:30
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.

3 participants