Repository navigation
fix(lsp): preserve generic closers before assignment - #1839
Merged
Lorenzobattistela merged 2 commits intoOct 23, 2026
Merged
Lorenzobattistela merged 2 commits into
Lorenzobattistela merged 2 commits into
Conversation
Lorenzobattistela
approved these changes
Oct 23, 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 generic closer adjacent to assignment can turn valid Bend into a parser error. This runs and prints
Done{7}, but formatting inserts a space before>=and makes it a comparison inside the annotation:Keep
>and=as separate tokens when glued to the preceding token or following a comma. Bend rejects a greater-than-headed infix glued to its left operand; a comma supplies no comparison operand. Reuse the existing angle spacing and tracking, while retaining spaced and leading-line>=comparisons.Blast radius
Only
tools/bend-fmt-lsp/src/formatter.tsand its existing test file change: one lexer predicate, one comment, and tests in the existing harness. No new tracking state, helper, parser, compiler, runtime, API, dependency or gate changes.Invalid glued comparisons such as
2>=1are no longer rewritten into valid spaced comparisons. Valid comparison behavior is preserved.Regression evidence
Two new fixtures exercise an ordinary typed binding and a continued tuple body. Both run before formatting, fail parsing after main's formatting in all three styles, and retain
Done{7}/(17, [3, 5])with this fix. A third fixture preserves active formatting with a trailing generic comma; two assertions retain spaced and leading-line>=. The existing harness checks exact text, idempotence and actual CLI output.Checks
npm test: 33/33, zero skips, including CLI regressions and LSP stdio.bun gates/repo.ts: 54/54 with CI-pinnedttok0.3.npm pack --dry-run --json: build succeeds; 14 expected files.git diff --check: passes.Validation limits
Validated locally on macOS with Node v26.8.2 and Bun 1.3.11. No Linux, other runtime versions, editor-client UI or cluster gates were run; LSP validation uses stdio. The focused CLI controls do not establish correctness for every possible token layout.