You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Format Document is not idempotent when a line break moves a token that enclosing nodes start at #65000
TypeScript 6.0.3's language service (getFormattingEditsForDocument) behaves the same way.
⏯ Playground Link
Not applicable: run Format Document twice on the code below (indent size 4, smart indentation).
💻 Code
{{0!("")}}
{{x+y}}
🙁 Actual behavior
The first format indents (""), and + y, by 8 spaces; formatting the result again moves them to 12. With an identifier callee, {{x\n("")}}, the first format already gives 12.
When a formatting rule adds a line break before a token, only the dynamic indenter of the token's own node is updated. In the first input that node is the non-null expression 0!; the call 0!("") and its statement start at the same token and moved too, but keep the indentation they inherited while everything was on one line. In the second input, the binary expression's continuation delta is reset although its statement starts at the same x.
🙂 Expected behavior
The first format gives the stable result, and formatting it again changes nothing.
Additional information about the issue
Found by fuzzing the formatter for idempotence in a fork of this repository. A fix with a regression test for both inputs is in #64994.
This report was drafted with Claude Code (Claude Opus 5.5).
Activity