The formatted output is structurally different from the input with `--verify-structure` (false positive)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Rust
- Star
- 468
- Fork
- 39
- Merge trung bình
- 6 giờ 24 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của GDQuest/GDScript-formatter
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
GDQuest/GDScript-formatter#365 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
GDQuest/GDScript-formatter#360 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
GDQuest/GDScript-formatter#354 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
GDQuest/GDScript-formatter#353 · 4 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 63/100
GDQuest/GDScript-formatter#348 · 3 bình luận · 2 reaction ·
Tất cả issue của GDQuest/GDScript-formatter
Issue tương tự
-
ai-priority/P2 bug db/oracle user-priority/P1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
swc-project/swc#12516 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
app bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
mls-rs-crypto-awslc: exact aws-lc-rs =1.16.3 pin blocks rustls security updateCó thể đã có người làm @muscariello đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100