Format Document is not idempotent when a line break moves a token that enclosing nodes start at
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 25/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- À l'abandon
- Stack technique
- typescript
Piste de recherche
The report gives two reproductions but names no formatter files or tests. Read the formatting and indentation logic for tokens moved by inserted line breaks, then inspect pull request #64994, which includes a proposed fix and regression tests for both inputs. Done means formatting either example twice produces the same result.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
🔎 Search Terms
format document, formatter, idempotent, idempotence, indentation, continuation indent, non-null assertion
🕗 Version & Regression Information
- TypeScript 7 at
main4a4b24d5dc96d148641ec6a39c4f5bbf023cbb2f (FormatDocument). - 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).
- Langage dominant
- Go
- Étoiles
- 112k
- Forks
- 15.4k
- Merge moyen
- 3 j 6 h
- PR mergées (30 j)
- 136
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoft/TypeScript
-
Native API: formatDiagnosticsWithColorAndContext drops related information without a file locationOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
microsoft/TypeScript#65087 ·
Les mainteneurs répondent en général sous 1 jour
-
API: `tsc.exe` opens a visible console window on Windows when the parent process has no consoleOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
microsoft/TypeScript#65083 ·
Les mainteneurs répondent en général sous 1 jour
-
TS7 LSP: documentHighlight returns nothing when the file path contains '@'Peut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. OuverteBug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
microsoft/TypeScript#64758 ·
Les mainteneurs répondent en général sous 1 jour
-
Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`Peut-être pris @rajnish-verma-22172 l’a pris il y a 12 jours. OuverteBug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
microsoft/TypeScript#64742 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Class names `eval` and `arguments` are not reported as invalid strict mode bindingsPeut-être pris @dmety l’a pris il y a 25 jours. OuverteBug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
microsoft/TypeScript#64661 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de microsoft/TypeScript
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
apache/arrow-swift#209 ·
Les mainteneurs répondent en général sous 1 jour
-
orchestrator: NFS-cache "cache path is not set" WARN logged on every build/launch instead of oncePeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 1/5 1-3 heures Accessibilité débutants 65/100
influxdata/telegraf#20031 ·
Les mainteneurs répondent en général sous 1 jour
-
pkg/registry/file no longer builds for GOOS=windows: unguarded syscall.Stat_t in qualified_resource_migration.goPeut-être pris @AnshulPatil2005 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
OneBusAway/maglev#1914 ·
Les mainteneurs répondent en général sous 2 jours