Repository navigation
fix(formatter): preserve inline lambda body alignment - #1583
Merged
Lorenzobattistela merged 2 commits intoOct 15, 2026
Merged
Conversation
Lorenzobattistela
approved these changes
Oct 15, 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 an inline lambda can move its aligned continuation to ordinary indentation, turning a valid program into a parse error. For example, a lambda containing two array writes prints
[7, 8]before formatting and fails afterwards.Recognize the first body token after
=>and reuse the existing column pins to move its continuations together. This adds two executable lines and follows the column-shift approach requested in #1302.Blast radius
Two bundled-tool files:
tools/bend-fmt-lsp/src/formatter.tsand its existing formatter test. The sharedformatBendpath serves direct callers and LSP formatting requests. Existing header state and delimiter tracking are preserved. There is no exported API or source compatibility break.The regression stays in the tool's own suite, following the external-tool gate guidance in #1389.
Regression evidence
Add one fixture to the existing pinned-layout cases, checking exact formatting, idempotence and equivalent execution through the real Bend CLI under default, four-space and tab options.
With the exact new test and the baseline formatter from
b869cca, the normal package build succeeds and tests report 28 passed, 2 expected failures, 0 skipped. Both failures catch the lambda defect: the expected continuation column and actual CLI execution. The corrected formatter preserves[7, 8]and passes the same checks.Checks
npm testintools/bend-fmt-lsp: TypeScript build and Node formatter/server suites; 30 passed, 0 failed, 0 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 formatting; the lambda regression exercises the shared formatter and real CLI, rather than an editor session. Windows, actual editor clients and mini-cluster gates were not run.