• R/O
  • SSH

vim: 提交

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

修訂56907027dba7a4fbfc648a209df12c18bad87d75 (tree)
時間2020-10-29 01:00:03
作者Bram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used

Commit: https://github.com/vim/vim/commit/171fb923b8f8da9fb0db1c8c86e35cf4e1339000
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Oct 28 16:54:47 2020 +0100

patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Problem: Vim9: function call is aborted even when "silent!" is used.
Solution: Use did_emsg instead of called_emsg. (closes https://github.com/vim/vim/issues/7213)

Change Summary

差異

diff -r 6a0c4559c941 -r 56907027dba7 src/testdir/test_vim9_func.vim
--- a/src/testdir/test_vim9_func.vim Wed Oct 28 14:45:04 2020 +0100
+++ b/src/testdir/test_vim9_func.vim Wed Oct 28 17:00:03 2020 +0100
@@ -1462,6 +1462,35 @@
14621462 call delete('XTest_silent_echo')
14631463 endfunc
14641464
1465+def SilentlyError()
1466+ execute('silent! invalid')
1467+ g:did_it = 'yes'
1468+enddef
1469+
1470+"func UserError()
1471+" silent! invalid
1472+"endfunc
1473+"
1474+"def SilentlyUserError()
1475+" UserError()
1476+" g:did_it = 'yes'
1477+"enddef
1478+
1479+" This can't be a :def function, because the assert would not be reached.
1480+" And this must not be inside a try/endtry.
1481+func Test_ignore_silent_error()
1482+ let g:did_it = 'no'
1483+ call SilentlyError()
1484+ call assert_equal('yes', g:did_it)
1485+
1486+" this doesn't work yet
1487+" let g:did_it = 'no'
1488+" call SilentlyUserError()
1489+" call assert_equal('yes', g:did_it)
1490+
1491+ unlet g:did_it
1492+endfunc
1493+
14651494 def Fibonacci(n: number): number
14661495 if n < 2
14671496 return n
diff -r 6a0c4559c941 -r 56907027dba7 src/version.c
--- a/src/version.c Wed Oct 28 14:45:04 2020 +0100
+++ b/src/version.c Wed Oct 28 17:00:03 2020 +0100
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 1916,
755+/**/
754756 1915,
755757 /**/
756758 1914,
diff -r 6a0c4559c941 -r 56907027dba7 src/vim9execute.c
--- a/src/vim9execute.c Wed Oct 28 14:45:04 2020 +0100
+++ b/src/vim9execute.c Wed Oct 28 17:00:03 2020 +0100
@@ -550,7 +550,7 @@
550550 {
551551 typval_T argvars[MAX_FUNC_ARGS];
552552 int idx;
553- int called_emsg_before = called_emsg;
553+ int did_emsg_before = did_emsg;
554554 ectx_T *prev_ectx = current_ectx;
555555
556556 if (call_prepare(argcount, argvars, ectx) == FAIL)
@@ -566,7 +566,7 @@
566566 for (idx = 0; idx < argcount; ++idx)
567567 clear_tv(&argvars[idx]);
568568
569- if (called_emsg != called_emsg_before)
569+ if (did_emsg != did_emsg_before)
570570 return FAIL;
571571 return OK;
572572 }
@@ -834,6 +834,7 @@
834834 msglist_T *private_msg_list = NULL;
835835 cmdmod_T save_cmdmod;
836836 int restore_cmdmod = FALSE;
837+ int trylevel_at_start = trylevel;
837838
838839 // Get pointer to item in the stack.
839840 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
@@ -2866,7 +2867,8 @@
28662867 continue;
28672868
28682869 on_error:
2869- if (trylevel == 0)
2870+ // If we are not inside a try-catch started here, abort execution.
2871+ if (trylevel <= trylevel_at_start)
28702872 goto failed;
28712873 }
28722874
Show on old repository browser