Repository navigation
fix(lsp): preserve body alignment after tuple commas - #1833
Merged
Lorenzobattistela merged 2 commits intoOct 23, 2026
Merged
Conversation
Lorenzobattistela
approved these changes
Oct 23, 2026
Merged
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.
Problem and fix
Formatting a continued tuple body after a comma can turn valid Bend into a parser error. For example, this runs and prints
(17, [3, 5]), but formatting moves the second array write out of the first write's column:Start the existing bounded body scope after commas at parenthesis depth, outside generic arguments. Continuation lines then move with their body anchor, as they already do after
(. This extends #1816 using #1803's existing scope expiry.Blast radius
Only
tools/bend-fmt-lsp/src/formatter.tsand its existing test file change. Parenthesis tracking limits the new origins to parenthesized comma sites, including call/declaration parentheses; commas inside generic arguments or unparenthesized array/constructor contexts are excluded. No parser, compiler, runtime, API, dependency or gate changes.Regression evidence
Two fixtures extend the existing exact-output/idempotence and real-CLI harnesses: a continued tuple item and a tuple followed by an observably consumed call argument. The original programs print
(17, [3, 5])and[28, 5]; formatted versions fail parsing on main in default, four-space and tab modes, and retain those outputs with the fix.Checks
npm test: 33/33, zero skips, including CLI regressions and the LSP stdio session.npm pack --dry-run --json: build succeeds; 14 expected package files.bun gates/repo.ts: 54/54 with CI-pinnedttok0.3.git diff --check: passes.Validation limits
Run locally on macOS with Node v26.8.2 and Bun 1.3.11. No Linux, other Node versions or editor-client UI validation; the LSP was tested over stdio. Cluster gates were not run. The token-based formatter's existing generic-close/assignment tokenization and unchanged-source fallback limitations remain outside this fix.