aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/funcs.c
diff options
context:
space:
mode:
authorShougo <Shougo.Matsu@gmail.com>2022-08-29 14:11:52 +0900
committerGitHub <noreply@github.com>2022-08-29 13:11:52 +0800
commit253f0ffd8d4784b7fca03f8f6c2455b9ee83ff9b (patch)
treec013d5603d348f69ea5d47c2bf0477df1504e623 /src/nvim/eval/funcs.c
parent1dcaa75a6564b8a90e74a96e242803c6aa3f59cf (diff)
downloadrneovim-253f0ffd8d4784b7fca03f8f6c2455b9ee83ff9b.tar.gz
rneovim-253f0ffd8d4784b7fca03f8f6c2455b9ee83ff9b.tar.bz2
rneovim-253f0ffd8d4784b7fca03f8f6c2455b9ee83ff9b.zip
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) https://github.com/vim/vim/commit/07ea5f1509fe8dafe3262ed2702b4d0fc99e288b
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r--src/nvim/eval/funcs.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 581f187140..2ed9ed34f4 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -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)
{