Skip to content

Commit 353e353

Browse files
authored
fix: multiline match pattern (#33)
1 parent 4b978ec commit 353e353

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

languages.ncl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
extensions = ["nu"],
55
grammar.source.git = {
66
git = "https://github.com/nushell/tree-sitter-nu.git",
7-
rev = "d9d6ad2c836bc3bd5010ab7850bc6da9498ca576",
7+
rev = "74ff80b2cff6d68286747a3de45531965ad2cf38",
88
},
99
},
1010
},

languages/nu.scm

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,15 @@
288288
entry: _ @prepend_spaced_softline
289289
)
290290

291-
;; match_arm
292-
(val_list
291+
(record_body
293292
entry: _ @append_space
294293
.
295294
entry: _ @prepend_spaced_softline
296295
)
297296

297+
;; match_arm
298298
(val_list
299-
entry: _
299+
(list_body)
300300
.
301301
rest: _ @prepend_spaced_softline
302302
)
@@ -305,18 +305,7 @@
305305
row: _ @prepend_spaced_softline
306306
)
307307

308-
(val_record
309-
entry: _ @append_space
310-
.
311-
entry: _ @prepend_spaced_softline
312-
)
313-
314-
(record_body
315-
entry: (record_entry) @append_space
316-
.
317-
entry: (record_entry) @prepend_spaced_softline
318-
)
319-
308+
;; type notation
320309
(collection_type
321310
[
322311
type: _

test/expected_ctrl.nu

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ match $foo {
2424
match $foo {
2525
[a b c] => 0
2626
a | b | c => 42
27+
a
28+
| b
29+
| c => 42
2730
{$bar $baz} => $baz
2831
# ..rest pattern
2932
[$x ..$y] if $x == 1 => { 'good list' }

test/input_ctrl.nu

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ match $foo {
2222
_ => {exit 0}
2323
}
2424
match $foo {
25-
[ a b c] => 0
25+
[ a b, c] => 0
2626
a|b|c => 42
27+
a
28+
|b|c => 42
2729
{ $bar $baz} => $baz
2830
# ..rest pattern
29-
[ $x ..$y ] if $x == 1 => { 'good list' }
31+
[ $x , ..$y ] if $x == 1 => { 'good list' }
3032
[ ..$y] => { $y }
3133
}
3234
match $foo {null => {return "default"} $val => $val}

0 commit comments

Comments
 (0)