From 4e8ec4900eb9fdc2a864e65d3de73c51e963abd0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 19 Jun 2024 05:47:25 +0800 Subject: vim-patch:9.1.0498: getcmdcompltype() interferes with cmdline completion (#29397) Problem: getcmdcompltype() interferes with cmdline completion. Solution: Don't set expand context when it's already set. (zeertzjq) closes: vim/vim#15036 https://github.com/vim/vim/commit/a821b609f9bb9daef032fe1cb8fb95995822e367 --- src/nvim/ex_getln.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index cef1868fc8..588f0aea13 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4072,18 +4072,22 @@ static char *get_cmdline_completion(void) return NULL; } - set_expand_context(p->xpc); - if (p->xpc->xp_context == EXPAND_UNSUCCESSFUL) { + int xp_context = p->xpc->xp_context; + if (xp_context == EXPAND_NOTHING) { + set_expand_context(p->xpc); + xp_context = p->xpc->xp_context; + p->xpc->xp_context = EXPAND_NOTHING; + } + if (xp_context == EXPAND_UNSUCCESSFUL) { return NULL; } - char *cmd_compl = get_user_cmd_complete(p->xpc, p->xpc->xp_context); + char *cmd_compl = get_user_cmd_complete(NULL, xp_context); if (cmd_compl == NULL) { return NULL; } - if (p->xpc->xp_context == EXPAND_USER_LIST - || p->xpc->xp_context == EXPAND_USER_DEFINED) { + if (xp_context == EXPAND_USER_LIST || 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); -- cgit