Skip to content

fix(lsp): preserve grouped semicolon body alignment - #1811

Merged
Lorenzobattistela merged 2 commits into
bendlang:mainfrom
vicmcorrea:fix/lsp-grouped-semicolon-alignment
Oct 21, 2026
Merged

Lorenzobattistela merged 2 commits into
bendlang:mainfrom
vicmcorrea:fix/lsp-grouped-semicolon-alignment

Conversation

@vicmcorrea

Copy link
Copy Markdown
Contributor

Problem and fix

A valid parenthesized array-update sequence prints [9, 8], but formatting a continuation after ; can move it away from its required column. The formatted program then fails to parse; the shared layout fingerprint accepts that output.

Let semicolons start the existing scoped body pins, as nested lambdas already do. This removes the special semicolon branch while retaining delimiter, argument-comma, and type-argument boundaries. Rename the existing scope stack and update its comment to cover both openers.

Blast radius

Two files in tools/bend-fmt-lsp: the inline-body scan in src/formatter.ts and fixtures in its existing CLI-backed tests. The change affects alignment before the existing fingerprint check. No public API or language compatibility break; no parser, compiler, runtime, gate, or dependency changes.

Regression evidence

Three added fixtures cover grouped array updates, generic commas, and a leading closer followed by another argument. Each original must print [9, 8]; all three indentation styles must actively change the source, preserve that output, and be idempotent. They reuse the existing test harness.

All nine added source/style combinations fail against main with expected ')' / observed 'a'. Existing lambda, delimiter, literal/comment, match-anchor, and declaration-boundary checks also pass.

Checks

  • npm test: build and all 33 tests pass, zero skips, including the LSP stdio session.
  • npm pack --dry-run: build passes; 14-file package inventory.
  • bun gates/repo.ts with CI-pinned ttok 0.3: 54/54.
  • git diff --check: passes.

Validation limits

Local checks use macOS arm64, Node 26.8.2 and Bun 1.3.11. No Linux run, interactive editor-client test, or cluster/CPU/GPU matrix. The three new CLI regressions use the source interpreter.

Some unusually far-indented argument layouts still return their original source through the existing fingerprint safeguard. A separate parenthesized update sequence without a semicolon remains outside this fix.

@Lorenzobattistela Lorenzobattistela self-assigned this Oct 21, 2026
@Lorenzobattistela
Lorenzobattistela merged commit c3d24d0 into bendlang:main Oct 21, 2026
1 check passed
@Lorenzobattistela Lorenzobattistela mentioned this pull request Oct 23, 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