aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-11-11 17:50:52 +0800
committerGitHub <noreply@github.com>2022-11-11 17:50:52 +0800
commit0d8e8d36ec7d3f4967f27389b4b94edf3ba57433 (patch)
tree94f62c40fbb8714ab4f811682e450fd8d7affd68
parentfc7ac688c397b5f748920597fcc70fe46e907944 (diff)
downloadrneovim-0d8e8d36ec7d3f4967f27389b4b94edf3ba57433.tar.gz
rneovim-0d8e8d36ec7d3f4967f27389b4b94edf3ba57433.tar.bz2
rneovim-0d8e8d36ec7d3f4967f27389b4b94edf3ba57433.zip
vim-patch:8.2.1919: assert_fails() setting emsg_silent changes normal execution (#20998)
Problem: Assert_fails() setting emsg_silent changes normal execution. Solution: Use a separate flag in_assert_fails. https://github.com/vim/vim/commit/28ee892ac4197421b3317f195512ca64cc56a5b4 Cherry-pick no_wait_return from patch 9.0.0846. Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/change.c2
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/globals.h3
-rw-r--r--src/nvim/insexpand.c2
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/normal.c1
-rw-r--r--src/nvim/screen.c3
-rw-r--r--src/nvim/testdir/test_autocmd.vim2
-rw-r--r--src/nvim/testdir/test_mapping.vim2
-rw-r--r--src/nvim/testdir/test_popup.vim6
-rw-r--r--src/nvim/testing.c15
-rw-r--r--src/nvim/ui.c2
13 files changed, 26 insertions, 18 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index fa0b2a83c8..78b058ea9a 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1842,7 +1842,7 @@ buf_T *buflist_new(char *ffname_arg, char *sfname_arg, linenr_T lnum, int flags)
pmap_put(handle_T)(&buffer_handles, buf->b_fnum, buf);
if (top_file_num < 0) { // wrap around (may cause duplicates)
emsg(_("W14: Warning: List of file names overflow"));
- if (emsg_silent == 0) {
+ if (emsg_silent == 0 && !in_assert_fails) {
ui_flush();
os_delay(3001L, true); // make sure it is noticed
}
diff --git a/src/nvim/change.c b/src/nvim/change.c
index c6df98651d..a62880dfc1 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -107,7 +107,7 @@ void changed(void)
// Wait two seconds, to make sure the user reads this unexpected
// message. Since we could be anywhere, call wait_return() now,
// 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) {
ui_flush();
os_delay(2002L, true);
wait_return(true);
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 414a32fab3..e1ffc27d5b 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -4946,7 +4946,7 @@ int buf_check_timestamp(buf_T *buf)
}
msg_clr_eos();
(void)msg_end();
- if (emsg_silent == 0) {
+ if (emsg_silent == 0 && !in_assert_fails) {
ui_flush();
// give the user some time to think about it
os_delay(1004L, true);
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 14266fc859..76f62fe267 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -195,7 +195,6 @@ EXTERN int emsg_skip INIT(= 0); // don't display errors for
EXTERN bool emsg_severe INIT(= false); // use message of next of several
// emsg() calls for throw
// used by assert_fails()
-EXTERN bool emsg_assert_fails_used INIT(= false);
EXTERN char *emsg_assert_fails_msg INIT(= NULL);
EXTERN long emsg_assert_fails_lnum INIT(= 0);
EXTERN char *emsg_assert_fails_context INIT(= NULL);
@@ -667,6 +666,8 @@ EXTERN int emsg_silent INIT(= 0); // don't print error messages
EXTERN bool emsg_noredir INIT(= false); // don't redirect error messages
EXTERN bool cmd_silent INIT(= false); // don't echo the command line
+EXTERN bool in_assert_fails INIT(= false); // assert_fails() active
+
// Values for swap_exists_action: what to do when swap file already exists
#define SEA_NONE 0 // don't use dialog
#define SEA_DIALOG 1 // use dialog when possible
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 2767d7939e..91ac1d5e8c 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -454,7 +454,7 @@ bool check_compl_option(bool dict_opt)
msg_attr((dict_opt
? _("'dictionary' option is empty")
: _("'thesaurus' option is empty")), HL_ATTR(HLF_E));
- if (emsg_silent == 0) {
+ if (emsg_silent == 0 && !in_assert_fails) {
vim_beep(BO_COMPL);
setcursor();
ui_flush();
diff --git a/src/nvim/message.c b/src/nvim/message.c
index d703f9f260..9fdd7a16a2 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -664,7 +664,7 @@ static bool emsg_multiline(const char *s, bool multiline)
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 = xstrdup(s);
emsg_assert_fails_lnum = SOURCING_LNUM;
xfree(emsg_assert_fails_context);
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 0999476ca4..27a7b1ae04 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -611,6 +611,7 @@ static bool normal_need_redraw_mode_message(NormalState *s)
&& stuff_empty()
&& typebuf_typed()
&& emsg_silent == 0
+ && !in_assert_fails
&& !did_wait_return
&& s->oa.op_type == OP_NOP);
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 2470fd326b..3f27302617 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -572,7 +572,8 @@ void check_for_delay(bool check_msg_scroll)
{
if ((emsg_on_display || (check_msg_scroll && msg_scroll))
&& !did_wait_return
- && emsg_silent == 0) {
+ && emsg_silent == 0
+ && !in_assert_fails) {
ui_flush();
os_delay(1006L, true);
emsg_on_display = false;
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index 1e9406eb87..f4c32599f1 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -175,7 +175,7 @@ func Test_autocmd_bufunload_avoiding_SEGV_01()
exe 'autocmd BufUnload <buffer> ' . (lastbuf + 1) . 'bwipeout!'
augroup END
- call assert_fails('edit bb.txt', ['E937:', 'E517:'])
+ call assert_fails('edit bb.txt', 'E937:')
autocmd! test_autocmd_bufunload
augroup! test_autocmd_bufunload
diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim
index 560883ba5d..522a51589f 100644
--- a/src/nvim/testdir/test_mapping.vim
+++ b/src/nvim/testdir/test_mapping.vim
@@ -779,7 +779,7 @@ func Test_expr_abbr()
" invalid <expr> abbreviation
abbr <expr> hte GetAbbr()
call assert_fails('normal ihte ', 'E117:')
- call assert_equal(' ', getline(1))
+ call assert_equal('', getline(1))
unabbr <expr> hte
close!
diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim
index 7f183f0849..0981329320 100644
--- a/src/nvim/testdir/test_popup.vim
+++ b/src/nvim/testdir/test_popup.vim
@@ -359,7 +359,7 @@ func Test_completefunc_opens_new_window_one()
/^one
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E565:')
call assert_equal(winid, win_getid())
- call assert_equal('oneDEF', getline(1))
+ call assert_equal('onedef', getline(1))
q!
endfunc
@@ -384,9 +384,7 @@ func Test_completefunc_opens_new_window_two()
/^two
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E565:')
call assert_equal(winid, win_getid())
- " v8.2.1919 hasn't been ported yet
- " call assert_equal('twodef', getline(1))
- call assert_equal('twoDEF', getline(1))
+ call assert_equal('twodef', getline(1))
q!
endfunc
diff --git a/src/nvim/testing.c b/src/nvim/testing.c
index 9dd41224da..a37ceeb86b 100644
--- a/src/nvim/testing.c
+++ b/src/nvim/testing.c
@@ -6,6 +6,8 @@
#include "nvim/eval.h"
#include "nvim/eval/encode.h"
#include "nvim/ex_docmd.h"
+#include "nvim/globals.h"
+#include "nvim/message.h"
#include "nvim/os/os.h"
#include "nvim/runtime.h"
#include "nvim/testing.h"
@@ -491,8 +493,8 @@ void f_assert_fails(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
// trylevel must be zero for a ":throw" command to be considered failed
trylevel = 0;
suppress_errthrow = true;
- emsg_silent = true;
- emsg_assert_fails_used = true;
+ in_assert_fails = true;
+ no_wait_return++;
do_cmdline_cmd(cmd);
if (called_emsg == called_emsg_before) {
@@ -584,9 +586,14 @@ void f_assert_fails(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
theend:
trylevel = save_trylevel;
suppress_errthrow = false;
- emsg_silent = false;
+ in_assert_fails = false;
+ did_emsg = false;
+ msg_col = 0;
+ no_wait_return--;
+ need_wait_return = false;
emsg_on_display = false;
- emsg_assert_fails_used = false;
+ msg_reset_scroll();
+ lines_left = Rows;
XFREE_CLEAR(emsg_assert_fails_msg);
set_vim_var_string(VV_ERRMSG, NULL, 0);
if (wrong_arg_msg != NULL) {
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index eb59d72e43..bee8d461a7 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -315,7 +315,7 @@ void vim_beep(unsigned val)
{
called_vim_beep = true;
- if (emsg_silent == 0) {
+ if (emsg_silent == 0 && !in_assert_fails) {
if (!((bo_flags & val) || (bo_flags & BO_ALL))) {
static int beeps = 0;
static uint64_t start_time = 0;