File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 223223
224224(parenthesized_expression "(" @append_antispace )
225225(parenthesized_expression
226- "(" @append_input_softline @append_indent_start
227- ")" @prepend_input_softline @prepend_indent_end
226+ "(" @append_input_softline @append_indent_start @append_indent_start
227+ ")" @prepend_input_softline @prepend_indent_end @prepend_indent_end
228228 (#multi_line_only!))
229+ (parenthesized_expression ")" @prepend_antispace (#multi_line_only!))
230+
231+ ; Remove the space added by binary operators when a multiline parenthesized
232+ ; expression closes immediately after them, as in:
233+ ; if (a or
234+ ; b):
235+ (parenthesized_expression
236+ (binary_operator) . ")" @prepend_antispace
237+ (#multi_line_only!))
229238
230239; LAMBDA
231240(lambda ":" @append_space (#single_line_only!))
Original file line number Diff line number Diff line change 1+ # This copies code provided by @twilit-jack in
2+ # https://github.com/GDQuest/GDScript-formatter/issues/224 (Thanks!)
3+ # The issue compiled multiple cases combined here.
4+ func _test () -> void :
5+ var my_very_long_condition := true
6+ var my_other_very_long_condition := false
7+
8+ if (my_very_long_condition
9+ or my_other_very_long_condition ):
10+ pass
11+
12+ if (
13+ my_very_long_condition
14+ or my_other_very_long_condition
15+ ):
16+ pass
17+
18+ var party = [
19+ "Godot" ,
20+ "Godette" ,
21+ "Steve" ,
22+ ]
23+
24+ var character_dict = {
25+ "Name" : "Bob" ,
26+ "Age" : 27 ,
27+ "Job" : "Mechanic" ,
28+ }
29+
30+ enum Tile {
31+ BRICK ,
32+ FLOOR ,
33+ SPIKE ,
34+ TELEPORT ,
35+ }
Original file line number Diff line number Diff line change 11var my_callable : Callable = (
2- (func ():
3- my_var = 1 )
4- if some_condition else some_function )
2+ (func ():
3+ my_var = 1 )
4+ if some_condition else some_function )
Original file line number Diff line number Diff line change 11func foo ():
22 var angle_degrees = 135
33 var quadrant = (
4- "northeast" if angle_degrees <= 90
5- else "southeast" if angle_degrees <= 180
6- else "southwest" if angle_degrees <= 270
7- else "northwest"
4+ "northeast" if angle_degrees <= 90
5+ else "southeast" if angle_degrees <= 180
6+ else "southwest" if angle_degrees <= 270
7+ else "northwest"
88 )
99
1010 var quadrant_newlines = (
11- "northeast"
12- if angle_degrees <= 90
13- else "southeast"
14- if angle_degrees <= 180
15- else "southwest"
16- if angle_degrees <= 270
17- else "northwest"
11+ "northeast"
12+ if angle_degrees <= 90
13+ else "southeast"
14+ if angle_degrees <= 180
15+ else "southwest"
16+ if angle_degrees <= 270
17+ else "northwest"
1818 )
1919
2020 var position = Vector2 (250 , 350 )
2121 if (
22- position .x > 200 and position .x < 400
23- and position .y > 300 and position .y < 400
22+ position .x > 200 and position .x < 400
23+ and position .y > 300 and position .y < 400
2424 ):
2525 pass
2626
2727 var a = (
28- 1 + 2
28+ 1 + 2
2929 )
3030
3131 var a = [
@@ -38,10 +38,10 @@ func foo():
3838 ]
3939
4040 var sum = (1 +
41- 2
41+ 2
4242 )
4343
4444 var bitflags = (
45- 0x0b
46- | 0xa0
45+ 0x0b
46+ | 0xa0
4747 )
Original file line number Diff line number Diff line change 1+ # This copies code provided by @twilit-jack in
2+ # https://github.com/GDQuest/GDScript-formatter/issues/224 (Thanks!)
3+ # The issue compiled multiple cases combined here.
4+ func _test () -> void :
5+ var my_very_long_condition := true
6+ var my_other_very_long_condition := false
7+
8+ if (my_very_long_condition
9+ or my_other_very_long_condition ):
10+ pass
11+
12+ if (
13+ my_very_long_condition
14+ or my_other_very_long_condition
15+ ):
16+ pass
17+
18+ var party = [
19+ "Godot" ,
20+ "Godette" ,
21+ "Steve" ,
22+ ]
23+
24+ var character_dict = {
25+ "Name" : "Bob" ,
26+ "Age" : 27 ,
27+ "Job" : "Mechanic" ,
28+ }
29+
30+ enum Tile {
31+ BRICK ,
32+ FLOOR ,
33+ SPIKE ,
34+ TELEPORT ,
35+ }
You can’t perform that action at this time.
0 commit comments