summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKota Kato <peony.btn@gmail.com>2022-08-04 18:50:14 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-04 18:50:14 +0100
commit3d3f6ac09859905405f35f50b2b7c57ccf40fb47 (patch)
tree5190bab31b07a6261507939f7281486911f21ec1
parent398649ee44edeb309c77361de697320378104b70 (diff)
downloadvim-git-3d3f6ac09859905405f35f50b2b7c57ccf40fb47.tar.gz
patch 9.0.0140: execute() does not use the "legacy" command modifierv9.0.0140
Problem: execute() does not use the "legacy" command modifier. Solution: pass the command modifier in sticky_cmdmod_flags. (Kota Kato, closes #10845)
-rw-r--r--src/evalfunc.c5
-rw-r--r--src/testdir/test_vim9_cmd.vim36
-rw-r--r--src/version.c2
3 files changed, 43 insertions, 0 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index ef66aedf9..da2f35e5c 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3929,6 +3929,7 @@ execute_common(typval_T *argvars, typval_T *rettv, int arg_off)
int save_redir_off = redir_off;
garray_T save_ga;
int save_msg_col = msg_col;
+ int save_sticky_cmdmod_flags = sticky_cmdmod_flags;
int echo_output = FALSE;
rettv->vval.v_string = NULL;
@@ -3985,6 +3986,9 @@ execute_common(typval_T *argvars, typval_T *rettv, int arg_off)
if (!echo_output)
msg_col = 0; // prevent leading spaces
+ // For "legacy call execute('cmd')" and "vim9cmd execute('cmd')" apply the
+ // command modifiers to "cmd".
+ sticky_cmdmod_flags = cmdmod.cmod_flags & (CMOD_LEGACY | CMOD_VIM9CMD);
if (cmd != NULL)
do_cmdline_cmd(cmd);
else
@@ -3997,6 +4001,7 @@ execute_common(typval_T *argvars, typval_T *rettv, int arg_off)
DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT|DOCMD_KEYTYPED);
--list->lv_refcount;
}
+ sticky_cmdmod_flags = save_sticky_cmdmod_flags;
// Need to append a NUL to the result.
if (ga_grow(&redir_execute_ga, 1) == OK)
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index 7db8e50c8..fc1354e83 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -142,6 +142,42 @@ def Test_cmdmod_execute()
END
v9.CheckScriptSuccess(lines)
delfunc g:TheFunc
+
+ # vim9cmd execute(cmd) executes code in vim9 script context
+ lines =<< trim END
+ vim9cmd execute("g:vim9executetest = 'bar'")
+ call assert_equal('bar', g:vim9executetest)
+ END
+ v9.CheckScriptSuccess(lines)
+ unlet g:vim9executetest
+
+ lines =<< trim END
+ vim9cmd execute(["g:vim9executetest1 = 'baz'", "g:vim9executetest2 = 'foo'"])
+ call assert_equal('baz', g:vim9executetest1)
+ call assert_equal('foo', g:vim9executetest2)
+ END
+ v9.CheckScriptSuccess(lines)
+ unlet g:vim9executetest1
+ unlet g:vim9executetest2
+
+ # legacy call execute(cmd) executes code in vim script context
+ lines =<< trim END
+ vim9script
+ legacy call execute("let g:vim9executetest = 'bar'")
+ assert_equal('bar', g:vim9executetest)
+ END
+ v9.CheckScriptSuccess(lines)
+ unlet g:vim9executetest
+
+ lines =<< trim END
+ vim9script
+ legacy call execute(["let g:vim9executetest1 = 'baz'", "let g:vim9executetest2 = 'foo'"])
+ assert_equal('baz', g:vim9executetest1)
+ assert_equal('foo', g:vim9executetest2)
+ END
+ v9.CheckScriptSuccess(lines)
+ unlet g:vim9executetest1
+ unlet g:vim9executetest2
enddef
def Test_edit_wildcards()
diff --git a/src/version.c b/src/version.c
index d6bd4cbed..7b53bee9d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 140,
+/**/
139,
/**/
138,