Skip to content

fix(formatter): preserve semicolon body alignment - #1590

Merged
Lorenzobattistela merged 1 commit into
bendlang:mainfrom
vicmcorrea:fix/formatter-semicolon-alignment
Oct 16, 2026
Merged

Lorenzobattistela merged 1 commit into
bendlang:mainfrom
vicmcorrea:fix/formatter-semicolon-alignment

Conversation

@vicmcorrea

Copy link
Copy Markdown
Contributor

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, retaining open === 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 in src/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 test in tools/bend-fmt-lsp: TypeScript build and Node formatter/server suites; 31 passed, zero failed, zero skipped.
  • Supplemental real CLI checks cover multiple semicolons, rewrite bodies, final-newline/EOF variants and delimiter controls. Corrected formatting preserves execution and is idempotent.
  • Removing only the semicolon depth guard changes the delimiter controls, confirming their sensitivity.
  • Repository gate with CI-pinned ttok 0.3: 54/54.
  • 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.

@Lorenzobattistela Lorenzobattistela self-assigned this Oct 16, 2026
@Lorenzobattistela
Lorenzobattistela merged commit 50c1c37 into bendlang:main Oct 16, 2026
1 check passed
@Lorenzobattistela Lorenzobattistela mentioned this pull request Oct 20, 2026
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.

2 participants