summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-05 18:18:42 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-05 18:18:42 +0200
commit47e7d70b58e8bfc1daaf6d35569ef2dbd0339ddc (patch)
treeda0ee0e0f993d52a0c9761c614aa6686798a4bd4
parent846178a72ca0860073d47fc0dc95f98d15f1d921 (diff)
patch 8.2.1137: Vim9: modifiers not cleared after compiling functionv8.2.1137
Problem: Vim9: modifiers not cleared after compiling function. Solution: Clear command modifiers. (closes #6396)
-rw-r--r--src/ex_docmd.c53
-rw-r--r--src/proto/ex_docmd.pro1
-rw-r--r--src/testdir/dumps/Test_vim9_silent_echo.dump6
-rw-r--r--src/testdir/test_vim9_func.vim23
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c3
6 files changed, 61 insertions, 27 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index a5562cc28a..59778eb981 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -25,7 +25,6 @@ static char_u *do_one_cmd(char_u **, int, cstack_T *, char_u *(*fgetline)(int, v
static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, int), void *cookie);
static int if_level = 0; // depth in :if
#endif
-static void free_cmdmod(void);
static void append_command(char_u *cmd);
#ifndef FEAT_MENU
@@ -2611,32 +2610,10 @@ doend:
? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL);
#endif
- if (ea.verbose_save >= 0)
- p_verbose = ea.verbose_save;
-
- free_cmdmod();
+ undo_cmdmod(&ea, save_msg_scroll);
cmdmod = save_cmdmod;
reg_executing = save_reg_executing;
- if (ea.save_msg_silent != -1)
- {
- // messages could be enabled for a serious error, need to check if the
- // counters don't become negative
- if (!did_emsg || msg_silent > ea.save_msg_silent)
- msg_silent = ea.save_msg_silent;
- emsg_silent -= ea.did_esilent;
- if (emsg_silent < 0)
- emsg_silent = 0;
- // Restore msg_scroll, it's set by file I/O commands, even when no
- // message is actually displayed.
- msg_scroll = save_msg_scroll;
-
- // "silent reg" or "silent echo x" inside "redir" leaves msg_col
- // somewhere in the line. Put it back in the first column.
- if (redirecting())
- msg_col = 0;
- }
-
#ifdef HAVE_SANDBOX
if (ea.did_sandbox)
--sandbox;
@@ -2927,11 +2904,14 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
}
/*
- * Free contents of "cmdmod".
+ * Unod and free contents of "cmdmod".
*/
- static void
-free_cmdmod(void)
+ void
+undo_cmdmod(exarg_T *eap, int save_msg_scroll)
{
+ if (eap->verbose_save >= 0)
+ p_verbose = eap->verbose_save;
+
if (cmdmod.save_ei != NULL)
{
// Restore 'eventignore' to the value before ":noautocmd".
@@ -2942,6 +2922,25 @@ free_cmdmod(void)
if (cmdmod.filter_regmatch.regprog != NULL)
vim_regfree(cmdmod.filter_regmatch.regprog);
+
+ if (eap->save_msg_silent != -1)
+ {
+ // messages could be enabled for a serious error, need to check if the
+ // counters don't become negative
+ if (!did_emsg || msg_silent > eap->save_msg_silent)
+ msg_silent = eap->save_msg_silent;
+ emsg_silent -= eap->did_esilent;
+ if (emsg_silent < 0)
+ emsg_silent = 0;
+ // Restore msg_scroll, it's set by file I/O commands, even when no
+ // message is actually displayed.
+ msg_scroll = save_msg_scroll;
+
+ // "silent reg" or "silent echo x" inside "redir" leaves msg_col
+ // somewhere in the line. Put it back in the first column.
+ if (redirecting())
+ msg_col = 0;
+ }
}
/*
diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro
index 8f5ac10d4e..85050313b6 100644
--- a/src/proto/ex_docmd.pro
+++ b/src/proto/ex_docmd.pro
@@ -6,6 +6,7 @@ int getline_equal(char_u *(*fgetline)(int, void *, int, int), void *cookie, char
void *getline_cookie(char_u *(*fgetline)(int, void *, int, int), void *cookie);
char_u *getline_peek(char_u *(*fgetline)(int, void *, int, int), void *cookie);
int parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only);
+void undo_cmdmod(exarg_T *eap, int save_msg_scroll);
int parse_cmd_address(exarg_T *eap, char **errormsg, int silent);
int checkforcmd(char_u **pp, char *cmd, int len);
char_u *find_ex_command(exarg_T *eap, int *full, void *(*lookup)(char_u *, size_t, cctx_T *), cctx_T *cctx);
diff --git a/src/testdir/dumps/Test_vim9_silent_echo.dump b/src/testdir/dumps/Test_vim9_silent_echo.dump
new file mode 100644
index 0000000000..f5f7927859
--- /dev/null
+++ b/src/testdir/dumps/Test_vim9_silent_echo.dump
@@ -0,0 +1,6 @@
+| +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|a|b|c> @70
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index c3236fff15..761dd57252 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -3,6 +3,7 @@
source check.vim
source view_util.vim
source vim9.vim
+source screendump.vim
func Test_def_basic()
def SomeFunc(): string
@@ -903,5 +904,27 @@ def Test_line_continuation_in_def()
assert_equal('full', Line_continuation_in_def('.'))
enddef
+def Test_silent_echo()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ def EchoNothing()
+ silent echo ''
+ enddef
+ defcompile
+ END
+ writefile(lines, 'XTest_silent_echo')
+
+ " Check that the balloon shows up after a mouse move
+ let buf = RunVimInTerminal('-S XTest_silent_echo', {'rows': 6})
+ term_sendkeys(buf, ":abc")
+ call VerifyScreenDump(buf, 'Test_vim9_silent_echo', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XTest_silent_echo')
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/version.c b/src/version.c
index 23a94348f8..b6ed058e13 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1137,
+/**/
1136,
/**/
1135,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index e5a801a28e..ed069b740a 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -6809,6 +6809,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
exarg_T ea;
int starts_with_colon = FALSE;
char_u *cmd;
+ int save_msg_scroll = msg_scroll;
// Bail out on the first error to avoid a flood of errors and report
// the right line number when inside try/catch.
@@ -6897,6 +6898,8 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
line = (char_u *)"";
continue;
}
+ // TODO: use modifiers in the command
+ undo_cmdmod(&ea, save_msg_scroll);
// Skip ":call" to get to the function name.
if (checkforcmd(&ea.cmd, "call", 3))