diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-02-06 12:38:51 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-02-06 12:38:51 +0100 |
commit | 038e09ee7645731de0296d255aabb17603276443 (patch) | |
tree | 26fde6ff5abd96317ca5455594fc50fa17cd0dcf /src/ex_docmd.c | |
parent | 139348f3e8370826a1ceb10c73f7c7bb586f8125 (diff) | |
download | vim-git-038e09ee7645731de0296d255aabb17603276443.tar.gz |
patch 8.2.2468: not easy to get the full command name from a shortened onev8.2.2468
Problem: Not easy to get the full command name from a shortened one.
Solution: Add fullcommand(). (Martin Tournoij, closes #7777)
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r-- | src/ex_docmd.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index d31b56c8c..da499c9e4 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3668,6 +3668,33 @@ cmd_exists(char_u *name) return 0; // trailing garbage return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1)); } + +/* + * "fullcommand" function + */ + void +f_fullcommand(typval_T *argvars, typval_T *rettv) +{ + exarg_T ea; + char_u *name = argvars[0].vval.v_string; + char_u *p; + + while (name[0] != NUL && name[0] == ':') + name++; + name = skip_range(name, TRUE, NULL); + + rettv->v_type = VAR_STRING; + + ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; + ea.cmdidx = (cmdidx_T)0; + p = find_ex_command(&ea, NULL, NULL, 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); +} #endif cmdidx_T |