Format Document is not idempotent when a line break moves a token that enclosing nodes start at
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
🔎 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).
- Lenguaje dominante
- Go
- Estrellas
- 112k
- Forks
- 15.4k
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 126
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/TypeScript
-
Won't Fix
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
microsoft/TypeScript#65107 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Native API: formatDiagnosticsWithColorAndContext drops related information without a file locationPosiblemente ocupada @timurzvural la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
microsoft/TypeScript#65087 ·
Los mantenedores suelen responder en 1 día
-
TS7 LSP: documentHighlight returns nothing when the file path contains '@'Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoBug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/TypeScript#64758 ·
Los mantenedores suelen responder en 1 día
-
Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`Posiblemente ocupada @rajnish-verma-22172 la tomó hace 12 días. AbiertoBug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
microsoft/TypeScript#64742 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Class names `eval` and `arguments` are not reported as invalid strict mode bindingsPosiblemente ocupada @dmety la tomó hace 26 días. AbiertoBug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoft/TypeScript#64661 ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/TypeScript
Issues similares
-
bug good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
[mesheryctl] design delete fails when passing file or URL as positional argumentPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertocomponent/mesheryctl kind/bug language/go
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
meshery/meshery#22772 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
backend security size:S
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
limitlessprojects/Go-Hybrid#3342 ·
Los mantenedores suelen responder en 1 día
-
status/ready type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
buildpacks/pack#2733 ·
Los mantenedores suelen responder en 1 día