Skip to content

Commit 652de6b

Browse files
committed
Fix icon annotation being reordered below class_name when extends was
before class_name Close #295
1 parent 94c6985 commit 652de6b

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This file documents the changes made to the formatter with each release.
44

5-
## Unrelease - 0.23.0
5+
## Unreleased - 0.23.0
66

77
### Added
88

src/reorder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ pub fn build_reorder_plan<'a>(parent: Node<'a>, content: &'a str) -> ReorderPlan
145145
if kind == GDScriptNodeKind::Comment || kind == GDScriptNodeKind::RegionStart {
146146
is_child_attached_to_declaration[child_index] = true;
147147
} else if kind == GDScriptNodeKind::Annotation {
148-
// Make sure to keep tool at the top of the script, above class_name
149-
// and extends. Otherwise it's a syntax error.
148+
// Make sure to keep tool and icon at the top of the script, above
149+
// class_name and extends. Otherwise it's a syntax error.
150150
let annotation_name = get_node_text(child, content);
151-
if annotation_name.starts_with("@tool") {
151+
if annotation_name.starts_with("@tool") || annotation_name.starts_with("@icon") {
152152
items.push(ReorderItem {
153153
child_index,
154154
sub_child: None,

tests/reorder_code/expected/reorder_tool_annotation_before_class.gd renamed to tests/reorder_code/expected/reorder_tool_and_icon_annotations_before_class.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@tool
2+
@icon('res://addons/at-icons/node2d/comet.svg')
23
class_name Test
34
extends RefCounted
45

tests/reorder_code/input/reorder_tool_annotation_before_class.gd renamed to tests/reorder_code/input/reorder_tool_and_icon_annotations_before_class.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@tool
2+
@icon('res://addons/at-icons/node2d/comet.svg')
23
extends RefCounted
34
class_name Test
45

0 commit comments

Comments
 (0)