mirror of
https://github.com/zoriya/vim.git
synced 2025-12-20 14:15:18 +00:00
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Problem: Assert_fails() setting emsg_silent changes normal execution. Solution: Use a separate flag in_assert_fails.
This commit is contained in:
@@ -2154,7 +2154,7 @@ buflist_new(
|
|||||||
if (top_file_num < 0) // wrap around (may cause duplicates)
|
if (top_file_num < 0) // wrap around (may cause duplicates)
|
||||||
{
|
{
|
||||||
emsg(_("W14: Warning: List of file names overflow"));
|
emsg(_("W14: Warning: List of file names overflow"));
|
||||||
if (emsg_silent == 0)
|
if (emsg_silent == 0 && !in_assert_fails)
|
||||||
{
|
{
|
||||||
out_flush();
|
out_flush();
|
||||||
ui_delay(3001L, TRUE); // make sure it is noticed
|
ui_delay(3001L, TRUE); // make sure it is noticed
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ changed(void)
|
|||||||
// Wait two seconds, to make sure the user reads this unexpected
|
// Wait two seconds, to make sure the user reads this unexpected
|
||||||
// message. Since we could be anywhere, call wait_return() now,
|
// message. Since we could be anywhere, call wait_return() now,
|
||||||
// and don't let the emsg() set msg_scroll.
|
// and don't let the emsg() set msg_scroll.
|
||||||
if (need_wait_return && emsg_silent == 0)
|
if (need_wait_return && emsg_silent == 0 && !in_assert_fails)
|
||||||
{
|
{
|
||||||
out_flush();
|
out_flush();
|
||||||
ui_delay(2002L, TRUE);
|
ui_delay(2002L, TRUE);
|
||||||
|
|||||||
@@ -4208,7 +4208,7 @@ buf_check_timestamp(
|
|||||||
msg_puts_attr(mesg2, HL_ATTR(HLF_W) + MSG_HIST);
|
msg_puts_attr(mesg2, HL_ATTR(HLF_W) + MSG_HIST);
|
||||||
msg_clr_eos();
|
msg_clr_eos();
|
||||||
(void)msg_end();
|
(void)msg_end();
|
||||||
if (emsg_silent == 0)
|
if (emsg_silent == 0 && !in_assert_fails)
|
||||||
{
|
{
|
||||||
out_flush();
|
out_flush();
|
||||||
#ifdef FEAT_GUI
|
#ifdef FEAT_GUI
|
||||||
|
|||||||
@@ -221,7 +221,6 @@ EXTERN int emsg_skip INIT(= 0); // don't display errors for
|
|||||||
EXTERN int emsg_severe INIT(= FALSE); // use message of next of several
|
EXTERN int emsg_severe INIT(= FALSE); // use message of next of several
|
||||||
// emsg() calls for throw
|
// emsg() calls for throw
|
||||||
// used by assert_fails()
|
// used by assert_fails()
|
||||||
EXTERN int emsg_assert_fails_used INIT(= FALSE);
|
|
||||||
EXTERN char_u *emsg_assert_fails_msg INIT(= NULL);
|
EXTERN char_u *emsg_assert_fails_msg INIT(= NULL);
|
||||||
EXTERN long emsg_assert_fails_lnum INIT(= 0);
|
EXTERN long emsg_assert_fails_lnum INIT(= 0);
|
||||||
EXTERN char_u *emsg_assert_fails_context INIT(= NULL);
|
EXTERN char_u *emsg_assert_fails_context INIT(= NULL);
|
||||||
@@ -1130,6 +1129,8 @@ EXTERN int emsg_silent INIT(= 0); // don't print error messages
|
|||||||
EXTERN int emsg_noredir INIT(= 0); // don't redirect error messages
|
EXTERN int emsg_noredir INIT(= 0); // don't redirect error messages
|
||||||
EXTERN int cmd_silent INIT(= FALSE); // don't echo the command line
|
EXTERN int cmd_silent INIT(= FALSE); // don't echo the command line
|
||||||
|
|
||||||
|
EXTERN int in_assert_fails INIT(= FALSE); // assert_fails() active
|
||||||
|
|
||||||
EXTERN int swap_exists_action INIT(= SEA_NONE);
|
EXTERN int swap_exists_action INIT(= SEA_NONE);
|
||||||
// For dialog when swap file already
|
// For dialog when swap file already
|
||||||
// exists.
|
// exists.
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ has_compl_option(int dict_opt)
|
|||||||
msg_attr(dict_opt ? _("'dictionary' option is empty")
|
msg_attr(dict_opt ? _("'dictionary' option is empty")
|
||||||
: _("'thesaurus' option is empty"),
|
: _("'thesaurus' option is empty"),
|
||||||
HL_ATTR(HLF_E));
|
HL_ATTR(HLF_E));
|
||||||
if (emsg_silent == 0)
|
if (emsg_silent == 0 && !in_assert_fails)
|
||||||
{
|
{
|
||||||
vim_beep(BO_COMPL);
|
vim_beep(BO_COMPL);
|
||||||
setcursor();
|
setcursor();
|
||||||
|
|||||||
@@ -659,7 +659,7 @@ emsg_core(char_u *s)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emsg_assert_fails_used && emsg_assert_fails_msg == NULL)
|
if (in_assert_fails && emsg_assert_fails_msg == NULL)
|
||||||
{
|
{
|
||||||
emsg_assert_fails_msg = vim_strsave(s);
|
emsg_assert_fails_msg = vim_strsave(s);
|
||||||
emsg_assert_fails_lnum = SOURCING_LNUM;
|
emsg_assert_fails_lnum = SOURCING_LNUM;
|
||||||
|
|||||||
@@ -1063,7 +1063,7 @@ vim_beep(
|
|||||||
called_vim_beep = TRUE;
|
called_vim_beep = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (emsg_silent == 0)
|
if (emsg_silent == 0 && !in_assert_fails)
|
||||||
{
|
{
|
||||||
if (!((bo_flags & val) || (bo_flags & BO_ALL)))
|
if (!((bo_flags & val) || (bo_flags & BO_ALL)))
|
||||||
{
|
{
|
||||||
@@ -2568,6 +2568,7 @@ goto_im(void)
|
|||||||
* But don't allow a space in the path, so that this works:
|
* But don't allow a space in the path, so that this works:
|
||||||
* "/usr/bin/csh --rcfile ~/.cshrc"
|
* "/usr/bin/csh --rcfile ~/.cshrc"
|
||||||
* But don't do that for Windows, it's common to have a space in the path.
|
* But don't do that for Windows, it's common to have a space in the path.
|
||||||
|
* Returns NULL when out of memory.
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
get_isolated_shell_name(void)
|
get_isolated_shell_name(void)
|
||||||
|
|||||||
@@ -1154,6 +1154,7 @@ getcount:
|
|||||||
&& stuff_empty()
|
&& stuff_empty()
|
||||||
&& typebuf_typed()
|
&& typebuf_typed()
|
||||||
&& emsg_silent == 0
|
&& emsg_silent == 0
|
||||||
|
&& !in_assert_fails
|
||||||
&& !did_wait_return
|
&& !did_wait_return
|
||||||
&& oap->op_type == OP_NOP)
|
&& oap->op_type == OP_NOP)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2490,7 +2490,8 @@ check_for_delay(int check_msg_scroll)
|
|||||||
{
|
{
|
||||||
if ((emsg_on_display || (check_msg_scroll && msg_scroll))
|
if ((emsg_on_display || (check_msg_scroll && msg_scroll))
|
||||||
&& !did_wait_return
|
&& !did_wait_return
|
||||||
&& emsg_silent == 0)
|
&& emsg_silent == 0
|
||||||
|
&& !in_assert_fails)
|
||||||
{
|
{
|
||||||
out_flush();
|
out_flush();
|
||||||
ui_delay(1006L, TRUE);
|
ui_delay(1006L, TRUE);
|
||||||
|
|||||||
@@ -1800,7 +1800,7 @@ report_default_term(char_u *term)
|
|||||||
mch_errmsg(_("defaulting to '"));
|
mch_errmsg(_("defaulting to '"));
|
||||||
mch_errmsg((char *)term);
|
mch_errmsg((char *)term);
|
||||||
mch_errmsg("'\r\n");
|
mch_errmsg("'\r\n");
|
||||||
if (emsg_silent == 0)
|
if (emsg_silent == 0 && !in_assert_fails)
|
||||||
{
|
{
|
||||||
screen_start(); // don't know where cursor is now
|
screen_start(); // don't know where cursor is now
|
||||||
out_flush();
|
out_flush();
|
||||||
|
|||||||
@@ -200,8 +200,8 @@ while 1
|
|||||||
" setting an option can only fail when it's implemented.
|
" setting an option can only fail when it's implemented.
|
||||||
call add(script, "if exists('+" . name . "')")
|
call add(script, "if exists('+" . name . "')")
|
||||||
for val in a[1]
|
for val in a[1]
|
||||||
call add(script, "call assert_fails('set " . name . "=" . val . "')")
|
call add(script, "silent! call assert_fails('set " . name . "=" . val . "')")
|
||||||
call add(script, "call assert_fails('set " . shortname . "=" . val . "')")
|
call add(script, "silent! call assert_fails('set " . shortname . "=" . val . "')")
|
||||||
endfor
|
endfor
|
||||||
call add(script, "endif")
|
call add(script, "endif")
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ func Test_autocmd_bufunload_avoiding_SEGV_01()
|
|||||||
exe 'autocmd BufUnload <buffer> ' . (lastbuf + 1) . 'bwipeout!'
|
exe 'autocmd BufUnload <buffer> ' . (lastbuf + 1) . 'bwipeout!'
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
call assert_fails('edit bb.txt', ['E937:', 'E517:'])
|
call assert_fails('edit bb.txt', 'E937:')
|
||||||
|
|
||||||
autocmd! test_autocmd_bufunload
|
autocmd! test_autocmd_bufunload
|
||||||
augroup! test_autocmd_bufunload
|
augroup! test_autocmd_bufunload
|
||||||
@@ -1768,7 +1768,7 @@ endfunc
|
|||||||
func Test_nocatch_wipe_all_buffers()
|
func Test_nocatch_wipe_all_buffers()
|
||||||
" Real nasty autocommand: wipe all buffers on any event.
|
" Real nasty autocommand: wipe all buffers on any event.
|
||||||
au * * bwipe *
|
au * * bwipe *
|
||||||
call assert_fails('next x', ['E94:', 'E517:'])
|
call assert_fails('next x', ['E94:', 'E937:'])
|
||||||
bwipe
|
bwipe
|
||||||
au!
|
au!
|
||||||
endfunc
|
endfunc
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ func Test_completefunc_opens_new_window_one()
|
|||||||
/^one
|
/^one
|
||||||
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E578:')
|
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E578:')
|
||||||
call assert_equal(winid, win_getid())
|
call assert_equal(winid, win_getid())
|
||||||
call assert_equal('oneDEF', getline(1))
|
call assert_equal('onedef', getline(1))
|
||||||
q!
|
q!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func Test_terminal_make_change()
|
|||||||
|
|
||||||
setlocal modifiable
|
setlocal modifiable
|
||||||
exe "normal Axxx\<Esc>"
|
exe "normal Axxx\<Esc>"
|
||||||
call assert_fails(buf . 'bwipe', ['E89:', 'E517:'])
|
call assert_fails(buf . 'bwipe', 'E89:')
|
||||||
undo
|
undo
|
||||||
|
|
||||||
exe buf . 'bwipe'
|
exe buf . 'bwipe'
|
||||||
@@ -89,7 +89,7 @@ endfunc
|
|||||||
|
|
||||||
func Test_terminal_wipe_buffer()
|
func Test_terminal_wipe_buffer()
|
||||||
let buf = Run_shell_in_terminal({})
|
let buf = Run_shell_in_terminal({})
|
||||||
call assert_fails(buf . 'bwipe', ['E89:', 'E517:'])
|
call assert_fails(buf . 'bwipe', 'E89:')
|
||||||
exe buf . 'bwipe!'
|
exe buf . 'bwipe!'
|
||||||
call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
|
call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
|
||||||
call assert_equal("", bufname(buf))
|
call assert_equal("", bufname(buf))
|
||||||
@@ -648,7 +648,7 @@ endfunc
|
|||||||
|
|
||||||
func Test_terminal_list_args()
|
func Test_terminal_list_args()
|
||||||
let buf = term_start([&shell, &shellcmdflag, 'echo "123"'])
|
let buf = term_start([&shell, &shellcmdflag, 'echo "123"'])
|
||||||
call assert_fails(buf . 'bwipe', ['E89:', 'E517:'])
|
call assert_fails(buf . 'bwipe', 'E89:')
|
||||||
exe buf . 'bwipe!'
|
exe buf . 'bwipe!'
|
||||||
call assert_equal("", bufname(buf))
|
call assert_equal("", bufname(buf))
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -1467,14 +1467,14 @@ def SilentlyError()
|
|||||||
g:did_it = 'yes'
|
g:did_it = 'yes'
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
"func UserError()
|
func UserError()
|
||||||
" silent! invalid
|
silent! invalid
|
||||||
"endfunc
|
endfunc
|
||||||
"
|
|
||||||
"def SilentlyUserError()
|
def SilentlyUserError()
|
||||||
" UserError()
|
UserError()
|
||||||
" g:did_it = 'yes'
|
g:did_it = 'yes'
|
||||||
"enddef
|
enddef
|
||||||
|
|
||||||
" This can't be a :def function, because the assert would not be reached.
|
" This can't be a :def function, because the assert would not be reached.
|
||||||
" And this must not be inside a try/endtry.
|
" And this must not be inside a try/endtry.
|
||||||
@@ -1483,10 +1483,9 @@ func Test_ignore_silent_error()
|
|||||||
call SilentlyError()
|
call SilentlyError()
|
||||||
call assert_equal('yes', g:did_it)
|
call assert_equal('yes', g:did_it)
|
||||||
|
|
||||||
" this doesn't work yet
|
let g:did_it = 'no'
|
||||||
" let g:did_it = 'no'
|
call SilentlyUserError()
|
||||||
" call SilentlyUserError()
|
call assert_equal('yes', g:did_it)
|
||||||
" call assert_equal('yes', g:did_it)
|
|
||||||
|
|
||||||
unlet g:did_it
|
unlet g:did_it
|
||||||
endfunc
|
endfunc
|
||||||
|
|||||||
@@ -555,8 +555,7 @@ f_assert_fails(typval_T *argvars, typval_T *rettv)
|
|||||||
// trylevel must be zero for a ":throw" command to be considered failed
|
// trylevel must be zero for a ":throw" command to be considered failed
|
||||||
trylevel = 0;
|
trylevel = 0;
|
||||||
suppress_errthrow = TRUE;
|
suppress_errthrow = TRUE;
|
||||||
emsg_silent = TRUE;
|
in_assert_fails = TRUE;
|
||||||
emsg_assert_fails_used = TRUE;
|
|
||||||
|
|
||||||
do_cmdline_cmd(cmd);
|
do_cmdline_cmd(cmd);
|
||||||
if (called_emsg == called_emsg_before)
|
if (called_emsg == called_emsg_before)
|
||||||
@@ -679,9 +678,13 @@ f_assert_fails(typval_T *argvars, typval_T *rettv)
|
|||||||
theend:
|
theend:
|
||||||
trylevel = save_trylevel;
|
trylevel = save_trylevel;
|
||||||
suppress_errthrow = FALSE;
|
suppress_errthrow = FALSE;
|
||||||
emsg_silent = FALSE;
|
in_assert_fails = FALSE;
|
||||||
|
did_emsg = FALSE;
|
||||||
|
msg_col = 0;
|
||||||
|
need_wait_return = FALSE;
|
||||||
emsg_on_display = FALSE;
|
emsg_on_display = FALSE;
|
||||||
emsg_assert_fails_used = FALSE;
|
msg_scrolled = 0;
|
||||||
|
lines_left = Rows;
|
||||||
VIM_CLEAR(emsg_assert_fails_msg);
|
VIM_CLEAR(emsg_assert_fails_msg);
|
||||||
set_vim_var_string(VV_ERRMSG, NULL, 0);
|
set_vim_var_string(VV_ERRMSG, NULL, 0);
|
||||||
if (wrong_arg_msg != NULL)
|
if (wrong_arg_msg != NULL)
|
||||||
|
|||||||
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1919,
|
||||||
/**/
|
/**/
|
||||||
1918,
|
1918,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ call_ufunc(ufunc_T *ufunc, int argcount, ectx_T *ectx, isn_T *iptr)
|
|||||||
funcexe_T funcexe;
|
funcexe_T funcexe;
|
||||||
int error;
|
int error;
|
||||||
int idx;
|
int idx;
|
||||||
int called_emsg_before = called_emsg;
|
int did_emsg_before = did_emsg;
|
||||||
|
|
||||||
if (ufunc->uf_def_status == UF_TO_BE_COMPILED
|
if (ufunc->uf_def_status == UF_TO_BE_COMPILED
|
||||||
&& compile_def_function(ufunc, FALSE, NULL) == FAIL)
|
&& compile_def_function(ufunc, FALSE, NULL) == FAIL)
|
||||||
@@ -620,7 +620,7 @@ call_ufunc(ufunc_T *ufunc, int argcount, ectx_T *ectx, isn_T *iptr)
|
|||||||
user_func_error(error, ufunc->uf_name);
|
user_func_error(error, ufunc->uf_name);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
if (called_emsg > called_emsg_before)
|
if (did_emsg > did_emsg_before)
|
||||||
// Error other than from calling the function itself.
|
// Error other than from calling the function itself.
|
||||||
return FAIL;
|
return FAIL;
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user