aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-12-25 23:26:59 -0500
committerGitHub <noreply@github.com>2021-12-25 23:26:59 -0500
commit9dd8557921ec94035971a3145ab744add858459a (patch)
treeae58196b839f3b1c6adc19e5da591d6ba46a5eb5 /src/nvim/ex_docmd.c
parent333dd6f80bc4345f72331f380a1010cfb2b6c621 (diff)
parent599a3d6abd29f4be9704361ea9e55656ac331a9b (diff)
downloadrneovim-9dd8557921ec94035971a3145ab744add858459a.tar.gz
rneovim-9dd8557921ec94035971a3145ab744add858459a.tar.bz2
rneovim-9dd8557921ec94035971a3145ab744add858459a.zip
Merge pull request #16774 from zeertzjq/vim-8.2.2468
vim-patch:8.2.2468: not easy to get the full command name from a shortened one
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 4d1804cd28..230cbd4b60 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -2900,6 +2900,31 @@ int cmd_exists(const char *const name)
return ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1);
}
+// "fullcommand" function
+void f_fullcommand(typval_T *argvars, typval_T *rettv, FunPtr fptr)
+{
+ exarg_T ea;
+ char_u *name = argvars[0].vval.v_string;
+
+ while (name[0] != NUL && name[0] == ':') {
+ name++;
+ }
+ name = skip_range(name, NULL);
+
+ rettv->v_type = VAR_STRING;
+
+ ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
+ ea.cmdidx = (cmdidx_T)0;
+ char_u *p = find_command(&ea, NULL);
+ if (p == NULL || ea.cmdidx == CMD_SIZE) {
+ return;
+ }
+
+ rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
+ ? get_user_commands(NULL, ea.useridx)
+ : cmdnames[ea.cmdidx].cmd_name);
+}
+
/// This is all pretty much copied from do_one_cmd(), with all the extra stuff
/// we don't need/want deleted. Maybe this could be done better if we didn't
/// repeat all this stuff. The only problem is that they may not stay