Skip to content

Commit cff10c2

Browse files
authored
feat: finally clause in ctrl_try (#243)
New finally keyword introduced in nu v0.111.0
1 parent bb3f533 commit cff10c2

8 files changed

Lines changed: 171026 additions & 167043 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
uses: actions/checkout@v4
3535
- name: Set up tree-sitter
3636
uses: tree-sitter/setup-action/cli@v2
37+
with:
38+
tree-sitter-ref: v0.25.10
3739
- name: Set up examples
3840
shell: bash
3941
run: |-

grammar.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,10 @@ function _ctrl_try_rule(parenthesized) {
15861586
keyword().catch,
15871587
field('catch_branch', $._blosure),
15881588
];
1589+
const seq_finally_array = [
1590+
keyword().finally,
1591+
field('finally_branch', $._blosure),
1592+
];
15891593
const seq_array = [
15901594
keyword().try,
15911595
field('try_branch', $.block),
@@ -1594,6 +1598,11 @@ function _ctrl_try_rule(parenthesized) {
15941598
_insert_newline($, seq_catch_array, true, false) :
15951599
seq(...seq_catch_array),
15961600
),
1601+
optional(
1602+
parenthesized ?
1603+
_insert_newline($, seq_finally_array, true, false) :
1604+
seq(...seq_finally_array),
1605+
),
15971606
];
15981607
return parenthesized ?
15991608
_insert_newline($, seq_array, false, false) :
@@ -1956,6 +1965,7 @@ function keyword() {
19561965
else: 'else',
19571966
try: 'try',
19581967
catch: 'catch',
1968+
finally: 'finally',
19591969
match: 'match',
19601970

19611971
in: 'in',

queries/nu/highlights.scm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
[
2323
"try"
2424
"catch"
25+
"finally"
2526
"error"
2627
] @keyword.exception
2728

script/known-failures.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ examples/nu_scripts/custom-completions/pytest/pytest-completions.nu
2121
examples/nu_scripts/custom-menus/current_session_history_menu.nu
2222
examples/nu_scripts/example-config/init.nu
2323
examples/nu_scripts/make_release/gen-ts-ext.nu
24+
examples/nu_scripts/make_release/notes/notice.nu
2425
examples/nu_scripts/make_release/notes/tools.nu
2526
examples/nu_scripts/modules/duplicates/example.nu
2627
examples/nu_scripts/modules/kubernetes/complete.nu

src/grammar.json

Lines changed: 119 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)