Repository navigation
fix(formatter): preserve semicolon body alignment - #1590
Merged
Lorenzobattistela merged 1 commit intoOct 16, 2026
Merged
Lorenzobattistela merged 1 commit into
Lorenzobattistela merged 1 commit into
Conversation
Lorenzobattistela
approved these changes
Oct 16, 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 valid inline binding followed by
;can misalign the following body. An array-update program that prints[7, 8]becomes a parse error because spaces inserted before its first update move that update farther than its aligned continuation.Recognize
;in the existing inline-body pin condition, retainingopen === 0. This reuses the column-shift approach requested in #1302 and preserves the delimiter restriction added by the maintainer in #1583.Blast radius
Two files in
tools/bend-fmt-lsp: one condition and its explanatory comment insrc/formatter.ts, plus regression coverage in the existing formatter test. The shared formatter serves direct callers and LSP formatting requests. There is no exported API or source compatibility break.The compiler, parser, LSP transport and root gates are unchanged. Tests stay in the tool's own suite, following #1389.
Regression evidence
Add the valid array-update program to the existing pinned-layout cases. It checks exact formatting, idempotence and equivalent execution through the real Bend CLI with default indentation, four spaces and tabs. Compact controls cover semicolons inside parentheses/brackets, literals and comments.
With the exact final tests and baseline formatter from
d2aeefc, the package builds successfully and reports 29 passed, 2 expected failures, zero skipped. Both failures catch this defect: the continuation column and actual CLI execution. The corrected formatter passes all 31 tests and preserves[7, 8].Checks
npm testintools/bend-fmt-lsp: TypeScript build and Node formatter/server suites; 31 passed, zero failed, zero skipped.git diff --check: passed.Validation limits
Local checks used macOS arm64, Node 26.8.2 and Bun 1.3.11. The existing stdio LSP test covers ordinary requests; the new regression exercises the shared formatter and actual CLI rather than an editor session. Full mini-cluster gates, GPU execution and other host platforms were not run. This fixes depth-zero semicolon body anchors without changing the existing nested-delimiter policy.