The formatted output is structurally different from the input with `--verify-structure` (false positive)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Rust
- Sterne
- 479
- Forks
- 40
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus GDQuest/GDScript-formatter
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
GDQuest/GDScript-formatter#365 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 58/100
GDQuest/GDScript-formatter#360 · 1 Kommentar ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
GDQuest/GDScript-formatter#354 · 2 Kommentare ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
GDQuest/GDScript-formatter#353 · 5 Kommentare ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 63/100
GDQuest/GDScript-formatter#348 · 3 Kommentare · 2 Reaktionen ·
Alle Issues in GDQuest/GDScript-formatter
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
status:untriaged
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
midnightntwrk/midnight-zk#592 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
QuartoHub: have the Document name before the filename in the browser tabEvtl. vergeben @cscheid hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
quarto-dev/q2#930 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
muse P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
HerringtonDarkholme/hd-lang#923 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag