Skip to content

Commit b66d3df

Browse files
Fix newlines in multiline ternaries being removed
1 parent 311d368 commit b66d3df

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

queries/gdscript.scm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@
212212

213213
; This is for ternary expressions, e.g. `a if b else c`
214214
(conditional_expression [("if") ("else")] @prepend_space @append_space)
215+
(parenthesized_expression (conditional_expression ("if") @prepend_input_softline))
215216
(parenthesized_expression (conditional_expression ("else") @prepend_input_softline))
217+
(conditional_expression (conditional_expression ("if") @prepend_input_softline))
216218
(conditional_expression (conditional_expression ("else") @prepend_input_softline))
217219

218220
(parenthesized_expression "(" @append_antispace)

tests/expected/multiline.gd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ func foo():
77
else "northwest"
88
)
99

10+
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"
18+
)
19+
1020
var position = Vector2(250, 350)
1121
if (
1222
position.x > 200 and position.x < 400

tests/input/multiline.gd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ func foo():
88
else "northwest"
99
)
1010

11+
var quadrant_newlines = (
12+
"northeast"
13+
if angle_degrees <= 90
14+
else "southeast"
15+
16+
if angle_degrees <= 180
17+
else "southwest"
18+
19+
if angle_degrees <= 270
20+
else "northwest"
21+
)
22+
1123
var position = Vector2(250, 350)
1224
if (
1325
position.x > 200 and position.x < 400

0 commit comments

Comments
 (0)