0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

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)
This commit is contained in:
Bram Moolenaar
2020-10-30 21:49:40 +01:00
parent d66960bf57
commit cd030c4b60
3 changed files with 23 additions and 1 deletions

View File

@@ -1477,7 +1477,6 @@ def SilentlyUserError()
enddef enddef
" This can't be a :def function, because the assert would not be reached. " This can't be a :def function, because the assert would not be reached.
" And this must not be inside a try/endtry.
func Test_ignore_silent_error() func Test_ignore_silent_error()
let g:did_it = 'no' let g:did_it = 'no'
call SilentlyError() call SilentlyError()
@@ -1490,6 +1489,23 @@ func Test_ignore_silent_error()
unlet g:did_it unlet g:did_it
endfunc endfunc
def Test_ignore_silent_error_in_filter()
var lines =<< trim END
vim9script
def Filter(winid: number, key: string): bool
if key == 'o'
silent! eval [][0]
return true
endif
return popup_filter_menu(winid, key)
enddef
popup_create('popup', #{filter: Filter})
feedkeys("o\r", 'xnt')
END
CheckScriptSuccess(lines)
enddef
def Fibonacci(n: number): number def Fibonacci(n: number): number
if n < 2 if n < 2
return n return n

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1928,
/**/ /**/
1927, 1927,
/**/ /**/

View File

@@ -2869,6 +2869,10 @@ func_return:
continue; continue;
on_error: on_error:
// If "emsg_silent" is set then ignore the error.
if (did_emsg == did_emsg_before && emsg_silent)
continue;
// If we are not inside a try-catch started here, abort execution. // If we are not inside a try-catch started here, abort execution.
if (trylevel <= trylevel_at_start) if (trylevel <= trylevel_at_start)
goto failed; goto failed;