0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.0.0473: fullcommand() only works for the current script version

Problem:    fullcommand() only works for the current script version.
Solution:   Add an optional argument for the script version.
This commit is contained in:
Bram Moolenaar
2022-09-15 21:46:02 +01:00
parent a4abe514ec
commit aa5341477c
5 changed files with 45 additions and 11 deletions

View File

@@ -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