Skip to content

Commit cd030c4

Browse files
committed
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Problem: Vim9: "silent!" not effective when list index is wrong. Solution: Ignore list indes failure when emsg_silent is set. (closes #7232)
1 parent d66960b commit cd030c4

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/testdir/test_vim9_func.vim

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,6 @@ def SilentlyUserError()
14771477
enddef
14781478

14791479
" This can't be a :def function, because the assert would not be reached.
1480-
" And this must not be inside a try/endtry.
14811480
func Test_ignore_silent_error()
14821481
let g:did_it = 'no'
14831482
call SilentlyError()
@@ -1490,6 +1489,23 @@ func Test_ignore_silent_error()
14901489
unlet g:did_it
14911490
endfunc
14921491

1492+
def Test_ignore_silent_error_in_filter()
1493+
var lines =<< trim END
1494+
vim9script
1495+
def Filter(winid: number, key: string): bool
1496+
if key == 'o'
1497+
silent! eval [][0]
1498+
return true
1499+
endif
1500+
return popup_filter_menu(winid, key)
1501+
enddef
1502+
1503+
popup_create('popup', #{filter: Filter})
1504+
feedkeys("o\r", 'xnt')
1505+
END
1506+
CheckScriptSuccess(lines)
1507+
enddef
1508+
14931509
def Fibonacci(n: number): number
14941510
if n < 2
14951511
return n

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1928,
753755
/**/
754756
1927,
755757
/**/

src/vim9execute.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,6 +2869,10 @@ call_def_function(
28692869
continue;
28702870

28712871
on_error:
2872+
// If "emsg_silent" is set then ignore the error.
2873+
if (did_emsg == did_emsg_before && emsg_silent)
2874+
continue;
2875+
28722876
// If we are not inside a try-catch started here, abort execution.
28732877
if (trylevel <= trylevel_at_start)
28742878
goto failed;

0 commit comments

Comments
 (0)