Skip to content

Commit 3a54e06

Browse files
committed
Fix extends with class name under 3 characters long not formatting properly
Close #82
1 parent 54952f5 commit 3a54e06

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ default-run = "gdscript-formatter"
1010
[dependencies]
1111
clap = { version = "4.0", features = ["derive"] }
1212
topiary-core = { git = "https://github.com/tweag/topiary", rev = "5081ccef9245fe56c2b3e2a7ced52277eda45825" }
13-
tree-sitter-gdscript = { git = "https://github.com/NathanLovato/tree-sitter-gdscript.git", branch = "gdquest/GDScript-formatter" }
13+
tree-sitter-gdscript = { git = "https://github.com/PrestonKnopp/tree-sitter-gdscript.git", rev = "bc3bfb680335692fd4fdfb99357cf3ecff0dacb6" }
1414
regex = "1.11"
1515
tree-sitter = "0.25.10"
1616
rayon = "1.11.0"

queries/gdscript.scm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,15 @@
8282
; CLASS DEFINITIONS
8383
(class_definition (class_body) @prepend_hardline @append_hardline)
8484
(class_definition (class_body (extends_statement) @append_hardline ))
85-
(class_name_statement) @append_space
8685
(class_definition) @prepend_hardline
86+
(class_definition extends: (extends_statement "extends" @prepend_space))
8787
(source
88-
(extends_statement) @append_delimiter @append_hardline
88+
(extends_statement "extends" @append_space) @append_delimiter @append_hardline
8989
(#delimiter! "\n"))
90-
(extends_statement) @prepend_space
90+
(source
91+
(class_name_statement
92+
extends: (extends_statement) @prepend_space)
93+
@append_delimiter @append_hardline (#delimiter! "\n"))
9194

9295
; CONST DEFINITIONS
9396
(const_statement ":" @append_space)

tests/expected/class_name.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
class_name Player extends CharacterBody2D
2+
3+
class_name UI extends Control

tests/input/class_name.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
class_name Player extends CharacterBody2D
2+
3+
class_name UI extends Control

0 commit comments

Comments
 (0)