patch 9.0.1774: no support for custom cmdline completion
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: #12228
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
diff --git a/src/ex_getln.c b/src/ex_getln.c
index dff7ec9..88eba32 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4152,6 +4152,7 @@
get_cmdline_completion(void)
{
cmdline_info_T *p;
+ char_u *buffer;
if (cmdline_star > 0)
return NULL;
@@ -4165,10 +4166,19 @@
return NULL;
char_u *cmd_compl = cmdcomplete_type_to_str(p->xpc->xp_context);
- if (cmd_compl != NULL)
- return vim_strsave(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)
+ {
+ buffer = alloc(STRLEN(cmd_compl) + STRLEN(p->xpc->xp_arg) + 2);
+ if (buffer == NULL)
+ return NULL;
+ sprintf((char *)buffer, "%s,%s", cmd_compl, p->xpc->xp_arg);
+ return buffer;
+ }
+
+ return vim_strsave(cmd_compl);
}
/*