summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-15 21:46:02 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-15 21:46:02 +0100
commitaa5341477c9f3840d63f709de3b9e5d0266f93d7 (patch)
treeed3a40bb10ad93bbf009e33ee6af623f409f3713 /src
parenta4abe514ecd9b7a038feed89f48476809775c80f (diff)
patch 9.0.0473: fullcommand() only works for the current script versionv9.0.0473
Problem: fullcommand() only works for the current script version. Solution: Add an optional argument for the script version.
Diffstat (limited to 'src')
-rw-r--r--src/ex_docmd.c30
-rw-r--r--src/testdir/test_cmdline.vim3
-rw-r--r--src/testdir/test_vim9_builtin.vim7
-rw-r--r--src/version.c2
4 files changed, 35 insertions, 7 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 0e5e1db5ec..814f1b6f8a 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -4048,20 +4048,31 @@ cmd_exists(char_u *name)
void
f_fullcommand(typval_T *argvars, typval_T *rettv)
{
- exarg_T ea;
- char_u *name;
- char_u *p;
+ exarg_T ea;
+ char_u *name;
+ char_u *p;
+ int vim9script = in_vim9script();
+ int save_cmod_flags = cmdmod.cmod_flags;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
- if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
+ if (in_vim9script()
+ && (check_for_string_arg(argvars, 0) == FAIL
+ || check_for_opt_bool_arg(argvars, 1) == FAIL))
return;
name = argvars[0].vval.v_string;
if (name == NULL)
return;
+ if (argvars[1].v_type != VAR_UNKNOWN)
+ {
+ vim9script = tv_get_bool(&argvars[1]);
+ cmdmod.cmod_flags &= ~(CMOD_VIM9CMD | CMOD_LEGACY);
+ cmdmod.cmod_flags |= vim9script ? CMOD_VIM9CMD : CMOD_LEGACY;
+ }
+
while (*name == ':')
name++;
name = skip_range(name, TRUE, NULL);
@@ -4069,10 +4080,13 @@ f_fullcommand(typval_T *argvars, typval_T *rettv)
ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
ea.cmdidx = (cmdidx_T)0;
ea.addr_count = 0;
+ ++emsg_silent; // don't complain about using "en" in Vim9 script
p = find_ex_command(&ea, NULL, NULL, NULL);
+ --emsg_silent;
if (p == NULL || ea.cmdidx == CMD_SIZE)
- return;
- if (in_vim9script())
+ goto theend;
+
+ if (vim9script)
{
int res;
@@ -4081,12 +4095,14 @@ f_fullcommand(typval_T *argvars, typval_T *rettv)
--emsg_silent;
if (res == FAIL)
- return;
+ goto theend;
}
rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
? get_user_command_name(ea.useridx, ea.cmdidx)
: cmdnames[ea.cmdidx].cmd_name);
+theend:
+ cmdmod.cmod_flags = save_cmod_flags;
}
#endif
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 7febc12269..27ca8bf841 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -662,6 +662,9 @@ func Test_fullcommand()
\ '3match': 'match',
\ 'aboveleft': 'aboveleft',
\ 'abo': 'aboveleft',
+ \ 'en': 'endif',
+ \ 'end': 'endif',
+ \ 'endi': 'endif',
\ 's': 'substitute',
\ '5s': 'substitute',
\ ':5s': 'substitute',
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 109cb35af6..dccd99bb32 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -1530,6 +1530,13 @@ def Test_fullcommand()
assert_equal('scriptnames', fullcommand('scr'))
assert_equal('', fullcommand('scg'))
fullcommand('')->assert_equal('')
+
+ assert_equal('', fullcommand('en'))
+ legacy call assert_equal('endif', fullcommand('en'))
+ assert_equal('endif', fullcommand('en', 0))
+ legacy call assert_equal('endif', fullcommand('en', 0))
+ assert_equal('', fullcommand('en', 1))
+ legacy call assert_equal('', fullcommand('en', 1))
enddef
def Test_funcref()
diff --git a/src/version.c b/src/version.c
index 77af684617..3f25033ecf 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 473,
+/**/
472,
/**/
471,