Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

The formatted output is structurally different from the input with `--verify-structure` (false positive)

Đang mở
#366 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
tooling

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của GDQuest/GDScript-formatter

Tất cả issue của GDQuest/GDScript-formatter

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.