summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-10-30 21:49:40 +0100
committerBram Moolenaar <Bram@vim.org>2020-10-30 21:49:40 +0100
commitcd030c4b604bea92311e9c418aefe5143dee9201 (patch)
tree2583b67a59c27bbd97896dee0edcd31f07009ae2 /src
parentd66960bf578410e83ef96ad2f4206b26a139d817 (diff)
downloadvim-git-cd030c4b604bea92311e9c418aefe5143dee9201.tar.gz
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrongv8.2.1928
Problem: Vim9: "silent!" not effective when list index is wrong. Solution: Ignore list indes failure when emsg_silent is set. (closes #7232)
Diffstat (limited to 'src')
-rw-r--r--src/testdir/test_vim9_func.vim18
-rw-r--r--src/version.c2
-rw-r--r--src/vim9execute.c4
3 files changed, 23 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 4ec0f6fdb..113e99e66 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1477,7 +1477,6 @@ def SilentlyUserError()
enddef
" 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()
let g:did_it = 'no'
call SilentlyError()
@@ -1490,6 +1489,23 @@ func Test_ignore_silent_error()
unlet g:did_it
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
if n < 2
return n
diff --git a/src/version.c b/src/version.c
index be975a7b5..65040460f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1928,
+/**/
1927,
/**/
1926,
diff --git a/src/vim9execute.c b/src/vim9execute.c
index abf88b1ae..33027871a 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -2869,6 +2869,10 @@ func_return:
continue;
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 (trylevel <= trylevel_at_start)
goto failed;