Skip to content

Commit 2be5733

Browse files
committed
patch 8.0.1518: error messages suppressed after ":silent! try"
Problem: Error messages suppressed after ":silent! try". (Ben Reilly) Solution: Restore emsg_silent before executing :try. (closes #2531)
1 parent bc19719 commit 2be5733

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/ex_docmd.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2880,8 +2880,18 @@ do_one_cmd(
28802880
}
28812881
#endif
28822882

2883+
/* The :try command saves the emsg_silent flag, reset it here when
2884+
* ":silent! try" was used, it should only apply to :try itself. */
2885+
if (ea.cmdidx == CMD_try && did_esilent > 0)
2886+
{
2887+
emsg_silent -= did_esilent;
2888+
if (emsg_silent < 0)
2889+
emsg_silent = 0;
2890+
did_esilent = 0;
2891+
}
2892+
28832893
/*
2884-
* 7. Switch on command name.
2894+
* 7. Execute the command.
28852895
*
28862896
* The "ea" structure holds the arguments that can be used.
28872897
*/

src/testdir/test_eval_stuff.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,17 @@ endfunction
1111
func Test_catch_return_with_error()
1212
call assert_equal(1, s:foo())
1313
endfunc
14+
15+
func Test_nocatch_restore_silent_emsg()
16+
silent! try
17+
throw 1
18+
catch
19+
endtry
20+
echoerr 'wrong'
21+
let c1 = nr2char(screenchar(&lines, 1))
22+
let c2 = nr2char(screenchar(&lines, 2))
23+
let c3 = nr2char(screenchar(&lines, 3))
24+
let c4 = nr2char(screenchar(&lines, 4))
25+
let c5 = nr2char(screenchar(&lines, 5))
26+
call assert_equal('wrong', c1 . c2 . c3 . c4 . c5)
27+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1518,
774776
/**/
775777
1517,
776778
/**/

0 commit comments

Comments
 (0)