Skip to content

Commit d6f5202

Browse files
committed
Add space after the opening brace and before closing braces of single line dictionaries
Close #43
1 parent 3bb366e commit d6f5202

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

queries/gdscript.scm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"{" @append_empty_softline @append_indent_start
3535
"}" @prepend_empty_softline @append_empty_softline @prepend_indent_end)
3636
(dictionary "," @append_spaced_softline . (comment)? @do_nothing)
37+
(dictionary "{" @append_space "}" @prepend_space (#single_line_only!))
3738
(pair ":" @append_space)
3839

3940
; FUNCTIONS

tests/expected/dictionaries.gd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The output has long lines wrapped to 100 characters and trailing commas.
2+
var dialogue_items: Array[Dictionary] = [
3+
{ "expression": expressions["regular"], "text": "I've been studying arrays and dictionaries lately.", "character": bodies["sophia"] },
4+
{ "expression": expressions["regular"], "text": "Oh, nice. How has it been going?", "character": bodies["pink"] },
5+
]
6+
# Single line dict should have a space after { and before }
7+
var my_dictionary = { key = "value" }
8+
# But only if it fits on one line
9+
var my_dictionary_2 = {
10+
key = "value"
11+
}

tests/expected/dictionary_long_strings.gd

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ var dialogue_items: Array[Dictionary] = [
33
{"expression" : expressions["regular"],"text": "I've been studying arrays and dictionaries lately.","character": bodies["sophia"]},
44
{ "expression" : expressions[ "regular"] , "text": "Oh, nice. How has it been going?","character": bodies["pink"] },
55
]
6+
# Single line dict should have a space after { and before }
7+
var my_dictionary = {key = "value"}
8+
# But only if it fits on one line
9+
var my_dictionary_2 = {
10+
key = "value"}

0 commit comments

Comments
 (0)