Export in combinantion with setter cause very weird behaviour
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
Look at the formatting logic for @export annotations combined with property setters in GDScript. The issue shows the formatter cycles between different layouts. Start by finding where export statements are parsed and formatted, likely in a module handling annotations or property declarations. Run the formatter on the provided code snippets to observe the non-deterministic behavior, then trace through the formatting decisions to see why it doesn't stabilize.
Written by the indexing model from the issue text.
Description
Ok, this is a really strange one.
The reformatter seems to be non deterministic in some cases.
Below I write a step by step guide to reproduce. I think that's best to follow through.
My initial code is:
@export_range(0., 500., .1, "or_greater", "suffix:m")
var max_distance_test: float = 200.:
set(value):
max_distance_test = value
Call reformatter and it changes it to:
@export_range(0., 500., .1, "or_greater", "suffix:m") var max_distance_test: float = 200.:
set(value):
max_distance_test = value
Call reformatter again and it changes it to:
@export_range(
0.,
500.,
.1,
"or_greater",
"suffix:m",
) var max_distance_test: float = 200.:
set(value):
max_distance_test = value
While the last one looks plain ugly, I think the initial one should have been already correct.
If the reformatting is indeed desired, it should have stopped after the first iteration, because the line length is not reached yet.
If I take the last one and simply add a line break before var:
@export_range(
0.,
500.,
.1,
"or_greater",
"suffix:m",
)
var max_distance_test: float = 200.:
set(value):
max_distance_test = value
Call reformatter again and it changes it back to the second iteration:
@export_range(0., 500., .1, "or_greater", "suffix:m") var max_distance_test: float = 200.:
set(value):
max_distance_test = value
From where a simple reformat call again brings us back to the ugly one.
In my script there are a bunch of such properties, therefore it is quite annoying that the reformatting can not decide on a layout.
Further more, any property without setter is left alone.
- Dominant language
- Rust
- Stars
- 458
- Forks
- 40
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GDQuest/GDScript-formatter
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
GDQuest/GDScript-formatter#362 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
GDQuest/GDScript-formatter#359 · 9 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
GDQuest/GDScript-formatter#327 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
GDQuest/GDScript-formatter#360 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
GDQuest/GDScript-formatter#354 · 2 comments ·
All issues in GDQuest/GDScript-formatter
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
TheLarkInn/aipm#2413 ·
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 90/100
alexgorbatchev/simple-ptt#15 ·
-
tooling
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
todo:ticket
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
taikoxyz/taiko-mono#22168 · 1 comment ·