vim-patch:9.0.0285: it is not easy to change the command line from a plugin (#19979)

vim-patch:9.0.0285: it is not easy to change the command line from a plugin

Problem:    It is not easy to change the command line from a plugin.
Solution:   Add setcmdline(). (Shougo Matsushita, closes vim/vim#10869)
07ea5f1509
This commit is contained in:
Shougo
2022-08-29 14:11:52 +09:00
committed by GitHub
parent 1dcaa75a65
commit 253f0ffd8d
6 changed files with 123 additions and 9 deletions

View File

@@ -7619,6 +7619,31 @@ static void f_setcharsearch(typval_T *argvars, typval_T *rettv, EvalFuncData fpt
}
}
/// "setcmdline()" function
static void f_setcmdline(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
if (argvars[0].v_type != VAR_STRING || argvars[0].vval.v_string == NULL) {
emsg(_(e_stringreq));
return;
}
int pos = -1;
if (argvars[1].v_type != VAR_UNKNOWN) {
bool error = false;
pos = (int)tv_get_number_chk(&argvars[1], &error) - 1;
if (error) {
return;
}
if (pos < 0) {
emsg(_(e_positive));
return;
}
}
rettv->vval.v_number = set_cmdline_str(argvars[0].vval.v_string, pos);
}
/// "setcmdpos()" function
static void f_setcmdpos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{