summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorichizok <gclient.gaap@gmail.com>2021-12-17 09:44:33 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-17 09:44:33 +0000
commitc3f91c0648f4b04a6a9ceb4ccec45ea767a63796 (patch)
tree79e2cead5ba42a7870c2cd903fd3146db2b81f1f
parent994a0a298bfbdd03e2eaae64268739d617080644 (diff)
downloadvim-git-c3f91c0648f4b04a6a9ceb4ccec45ea767a63796.tar.gz
patch 8.2.3833: error from term_start() not caught by try/catchv8.2.3833
Problem: Error from term_start() not caught by try/catch. Solution: save and restore did_emsg when applying autocommands. (Ozaki Kiichi, closes #9361)
-rw-r--r--src/autocmd.c5
-rw-r--r--src/testdir/test_terminal3.vim20
-rw-r--r--src/version.c2
3 files changed, 27 insertions, 0 deletions
diff --git a/src/autocmd.c b/src/autocmd.c
index 5ec911ab7..305679cf3 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -1891,6 +1891,7 @@ apply_autocmds_group(
int did_save_redobuff = FALSE;
save_redo_T save_redo;
int save_KeyTyped = KeyTyped;
+ int save_did_emsg;
ESTACK_CHECK_DECLARATION
/*
@@ -2171,9 +2172,13 @@ apply_autocmds_group(
// make sure cursor and topline are valid
check_lnums(TRUE);
+ save_did_emsg = did_emsg;
+
do_cmdline(NULL, getnextac, (void *)&patcmd,
DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT);
+ did_emsg += save_did_emsg;
+
if (nesting == 1)
// restore cursor and topline, unless they were changed
reset_lnums();
diff --git a/src/testdir/test_terminal3.vim b/src/testdir/test_terminal3.vim
index 9f84615f2..a351799a7 100644
--- a/src/testdir/test_terminal3.vim
+++ b/src/testdir/test_terminal3.vim
@@ -901,5 +901,25 @@ func Test_terminal_getwinpos()
only!
endfunc
+func Test_terminal_term_start_error()
+ func s:term_start_error() abort
+ try
+ return term_start([[]])
+ catch
+ return v:exception
+ finally
+ "
+ endtry
+ endfunc
+ autocmd WinEnter * call type(0)
+
+ " Must not crash in s:term_start_error, nor the exception thrown.
+ let result = s:term_start_error()
+ call assert_match('^Vim(return):E730:', result)
+
+ autocmd! WinEnter
+ delfunc s:term_start_error
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index e3fb7c2ff..b2f02eca5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3833,
+/**/
3832,
/**/
3831,