The formatted output is structurally different from the input with `--verify-structure` (false positive)
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Rust
- スター
- 468
- フォーク
- 39
- 平均マージ
- 6時間 24分
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
GDQuest/GDScript-formatter のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
GDQuest/GDScript-formatter#365 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
GDQuest/GDScript-formatter#360 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
GDQuest/GDScript-formatter#354 · コメント 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
GDQuest/GDScript-formatter#353 · コメント 5 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 63/100
GDQuest/GDScript-formatter#348 · コメント 3 件 · リアクション 2 件 ·
GDQuest/GDScript-formatter の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
state:triage-needed
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
scanaislop/aislop#482 ·
メンテナーはふだん 1 日以内に返信
-
docs(skills): issue-first should reference an existing Linear ticket instead of filing a duplicateオープンdocumentation
難易度 1/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
chatmail/core#8824 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信