Skip to content

Commit

Permalink
patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Browse files Browse the repository at this point in the history
Problem:    Vim9: Cannot use "fina" for "finally". (Naruhiko Nishino)
Solution:   Specifically check for "fina". (closes #7020)
  • Loading branch information
brammool committed Sep 26, 2020
1 parent d47f50b commit 373863e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/ex_docmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3420,6 +3420,10 @@ find_ex_command(
eap->cmdidx = CMD_SIZE;
}

// ":fina" means ":finally" for backwards compatibility.
if (eap->cmdidx == CMD_final && p - eap->cmd == 4)
eap->cmdidx = CMD_finally;

return p;
}

Expand Down
7 changes: 4 additions & 3 deletions src/testdir/test_trycatch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func T25_F()
if loops == 2
try
Xpath 'f' . loops
finally
final
Xpath 'g' . loops
endtry
endif
Expand All @@ -49,19 +49,20 @@ func T25_F()
Xpath 'i'
endfunc

" Also try using "fina" and "final" and "finall" as abbraviations.
func T25_G()
if 1
try
Xpath 'A'
call T25_F()
Xpath 'B'
finally
fina
Xpath 'C'
endtry
else
try
Xpath 'D'
finally
finall
Xpath 'E'
endtry
endif
Expand Down
4 changes: 2 additions & 2 deletions src/testdir/test_vim9_script.vim
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def Test_try_catch()
endtry
catch /wrong/
add(l, 'caught')
finally
fina
add(l, 'finally')
endtry
assert_equal(['1', 'caught', 'finally'], l)
Expand Down Expand Up @@ -526,7 +526,7 @@ enddef
def ReturnFinally(): string
try
return 'intry'
finally
finall
g:in_finally = 'finally'
endtry
return 'end'
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1746,
/**/
1745,
/**/
Expand Down

1 comment on commit 373863e

@mattn
Copy link
Member

@mattn mattn commented on 373863e Sep 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I suggest to revert include of final since syntax file will be broken.

Please sign in to comment.