vim-patch:9.0.1774: no support for custom cmdline completion (#24808)

Problem:  no support for custom cmdline completion
Solution: Add new vimscript functions

Add the following two functions:
- getcmdcompltype() returns custom and customlist functions

- getcompletion() supports both custom and customlist

closes: vim/vim#12228

92997dda78

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
This commit is contained in:
zeertzjq
2023-08-21 07:29:49 +08:00
committed by GitHub
parent ac99e63d73
commit 694814cdd5
7 changed files with 87 additions and 6 deletions

View File

@@ -4165,11 +4165,19 @@ static char *get_cmdline_completion(void)
}
char *cmd_compl = get_user_cmd_complete(p->xpc, p->xpc->xp_context);
if (cmd_compl != NULL) {
return xstrdup(cmd_compl);
if (cmd_compl == NULL) {
return NULL;
}
return NULL;
if (p->xpc->xp_context == EXPAND_USER_LIST
|| p->xpc->xp_context == EXPAND_USER_DEFINED) {
size_t buflen = strlen(cmd_compl) + strlen(p->xpc->xp_arg) + 2;
char *buffer = xmalloc(buflen);
snprintf(buffer, buflen, "%s,%s", cmd_compl, p->xpc->xp_arg);
return buffer;
}
return xstrdup(cmd_compl);
}
/// "getcmdcompltype()" function