Skip to content

Commit 0fc7dba

Browse files
authored
Merge pull request #39 from shadr/fix-more-inline-comments
Fix inline comments in arrays, dictionaries and enums
2 parents 0535c72 + 179536a commit 0fc7dba

3 files changed

Lines changed: 53 additions & 4 deletions

File tree

queries/gdscript.scm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@
2828
(array
2929
"[" @append_empty_softline @append_indent_start
3030
"]" @prepend_empty_softline @append_empty_softline @prepend_indent_end)
31+
(array "," @append_spaced_softline . (comment)? @do_nothing)
3132

32-
(array "," @append_spaced_softline)
3333
(dictionary
3434
"{" @append_empty_softline @append_indent_start
3535
"}" @prepend_empty_softline @append_empty_softline @prepend_indent_end)
36-
37-
(dictionary "," @append_spaced_softline)
36+
(dictionary "," @append_spaced_softline . (comment)? @do_nothing)
3837
(pair ":" @append_space)
3938

4039
; FUNCTIONS
@@ -83,7 +82,7 @@
8382
(enumerator_list
8483
"{" @append_input_softline @append_indent_start
8584
"}" @prepend_input_softline @prepend_indent_end)
86-
(enumerator_list "," @append_spaced_softline)
85+
(enumerator_list "," @append_spaced_softline . (comment)? @do_nothing)
8786
(enumerator_list) @prepend_space
8887

8988
; CONSTRUCTORS

tests/expected/comments_inline.gd

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,37 @@ var prop = 10: # var comment
55
get: # get comment
66
return prop
77

8+
enum Foo {
9+
A, # Comment
10+
B, # Comment
11+
C
12+
}
13+
814

915
class InnerClass: # class comment
1016
pass
1117

1218

1319
func _init(): # constructor comment
20+
var lua_dict = {
21+
# Comment
22+
a = 0, # Comment
23+
# Comment
24+
b = 1, # Comment
25+
# Comment
26+
}
27+
28+
var arr = [
29+
1, # Comment
30+
2, # Comment
31+
# Comment
32+
2,
33+
# Comment
34+
# Comment 2
35+
2,
36+
# Comment
37+
3, # Comment
38+
]
1439
pass
1540

1641

tests/input/comments_inline.gd

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,35 @@ var prop = 10: # var comment
55
get: # get comment
66
return prop
77

8+
enum Foo {
9+
A, # Comment
10+
B,# Comment
11+
C
12+
}
13+
814
class InnerClass: # class comment
915
pass
1016

1117
func _init(): # constructor comment
18+
var lua_dict = {
19+
# Comment
20+
a = 0, # Comment
21+
# Comment
22+
b = 1, # Comment
23+
# Comment
24+
}
25+
26+
var arr = [
27+
1, # Comment
28+
2, # Comment
29+
# Comment
30+
2,
31+
# Comment
32+
# Comment 2
33+
2,
34+
# Comment
35+
3,# Comment
36+
]
1237
pass
1338

1439
func foo(): # func comment

0 commit comments

Comments
 (0)