The formatted output is structurally different from the input with `--verify-structure` (false positive)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
Start by locating the formatter’s parsing and line-breaking code, then trace how --verify-structure compares the input with formatted output. Reproduce the reported case with the two-line GDScript example and check whether backslash line continuations are treated consistently in both paths. Done means verification accepts the formatter’s output and unnecessary continuations are handled as described; the issue does not name specific files or tests.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I found a case where --verify-structure fails. I think it's a false positive.
$ gdscript-formatter example.gd --verify-structure
Formatting 1 file...Error: "Failed to format file example.gd: The formatted output is structurally different from the input. Please report this to the bug tracker with a copy of the input code: https://github.com/GDQuest/GDScript-formatter/issues/"
I stripped down the failing file to a minimal example with just the line that causes the issue:
func _process(_delta: float) -> void:
unit.followTarget = unit.position.distance_to(unit.targetUnit.position) > Global.getAbility[abilityIdsPrioritized[0]].targetRange
Here is what it becomes after applying the formatting:
func _process(_delta: float) -> void:
unit.followTarget = unit.position.distance_to(unit.targetUnit.position) > Global \
.getAbility[abilityIdsPrioritized[0]] \
.targetRange
I tested this formatted version and it still works.
The problem seems to be that the formatter is able to break long lines with \, but when parsing a file it does not recognize lines broken with \ as one line, so it thinks the file is now different.
That also means that the formatter does not put a line back together if it has unnecessary line breaks.
F.ex. if I do something weird like this (which is still the exact same code):
func _process(_delta: float) -> void:
unit \
.\
followTarget = unit.position.distance_to(unit.targetUnit.position) > Global \
.\
getAbility[abilityIdsPrioritized[0]]\
.targetRange
All the formatter does with it is add some indents. Ideally it should remove the unnecessary line breaks.
Suggestion
The formatter could as part of the format and --verify-structure operations start by replacing all \ line breaks with a whitespace.
Then it will be "blind" to whatever line breaks already exist and always consistently add the line breaks it deems necessary.
It could have an option to enable/disable.
- Lenguaje dominante
- Rust
- Estrellas
- 468
- Forks
- 39
- Merge medio
- 6 h 24 min
- PR fusionados (30 d)
- 3
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 GDQuest/GDScript-formatter
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
GDQuest/GDScript-formatter#365 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
GDQuest/GDScript-formatter#360 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
GDQuest/GDScript-formatter#354 · 2 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
GDQuest/GDScript-formatter#353 · 5 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 63/100
GDQuest/GDScript-formatter#348 · 3 comentarios · 2 reacciones ·
Todos los issues de GDQuest/GDScript-formatter
Issues similares
-
Trash, bin or rubbish?Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 63/100
pop-os/cosmic-files#2117 ·
Los mantenedores suelen responder en 2 días
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
dependabot/dependabot-core#16547 ·
Los mantenedores suelen responder en 1 día
-
bug status:ready-for-test
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
UniClipboard/UniClipboard#1985 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
RustCrypto/SSH#596 ·
-
area:breg rust
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
registrystack/registry-stack#2034 ·
Los mantenedores suelen responder en 1 día