]> granicus.if.org Git - vim/commitdiff
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong v8.2.1928
authorBram Moolenaar <Bram@vim.org>
Fri, 30 Oct 2020 20:49:40 +0000 (21:49 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 30 Oct 2020 20:49:40 +0000 (21:49 +0100)
Problem:    Vim9: "silent!" not effective when list index is wrong.
Solution:   Ignore list indes failure when emsg_silent is set. (closes #7232)

src/testdir/test_vim9_func.vim
src/version.c
src/vim9execute.c

index 4ec0f6fdbcf085829d90948a53948d63909d9c92..113e99e6668b2151b0c6a58420a9005e9ebd0242 100644 (file)
@@ -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
index be975a7b50bc84aecfbbefa136c2ea8703f9f3ce..65040460f170e50564b61c26429886d9245b76d9 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1928,
 /**/
     1927,
 /**/
index abf88b1aef9b3f4532b65130dfbbc902550f4a81..33027871a0be49a7d58a2583f59d83e1ef89aa5b 100644 (file)
@@ -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;