Skip to content

fix(lsp): preserve body alignment after opening parentheses - #1816

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

Lorenzobattistela merged 2 commits into
bendlang:mainfrom
vicmcorrea:fix/lsp-paren-body-alignment

Conversation

@vicmcorrea

Copy link
Copy Markdown
Contributor

Problem and fix

A valid body beginning on the same line as ( can lose its statement column during formatting. A grouped array-update sequence then fails to parse, even though the existing fingerprint accepts the output.

Start the existing bounded body scope at the first token after (. Its continuation lines move with that token, using the existing delimiter, type-angle and argument-comma expiry. Update the comment to name this opener; no new helper or state.

Blast radius

Two files in tools/bend-fmt-lsp: the formatter's alignment scan before the existing fingerprint check, and fixtures in its current CLI-backed tests. The scanner also handles call/parameter parentheses. No parser, compiler, runtime, public API, dependency or gate changes.

Regression evidence

Two added fixtures cover grouped updates and a leading closer with an observable following argument. All three indentation styles actively change the source, preserve its CLI output and remain idempotent. Five of the six baseline variants fail parsing; the plain group's tab variant already works. The updated permanent test fails with main's formatter at expected ')' / observed 'a'.

Checks

  • npm test: build and 33/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 ran on macOS arm64. No interactive editor-client test, Linux run, cluster or GPU/backend matrix. A body starting directly after a tuple comma remains a known pre-existing failure; this change adds only the ( origin. Some far-indented layouts still retain their input through the existing fingerprint safeguard.

@Lorenzobattistela
Lorenzobattistela merged commit de26a91 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