aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/cmdexpand.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-16 06:07:01 +0800
committerGitHub <noreply@github.com>2023-08-16 06:07:01 +0800
commit3cd5ef63fd17a4eb294856360039803f31a10a76 (patch)
tree12fad468cc5026ef6b706a874b3d439ea57390e9 /src/nvim/cmdexpand.c
parente72c0cd92090c1fc1e5665a060b3e1d0094d7f30 (diff)
downloadrneovim-3cd5ef63fd17a4eb294856360039803f31a10a76.tar.gz
rneovim-3cd5ef63fd17a4eb294856360039803f31a10a76.tar.bz2
rneovim-3cd5ef63fd17a4eb294856360039803f31a10a76.zip
vim-patch:9.0.1714: getcompletion() "cmdline" fails after :autocmd (#24727)
Problem: getcompletion() "cmdline" fails after :autocmd Solution: Use set_cmd_context() instead of set_one_cmd_context(). closes: vim/vim#12804 https://github.com/vim/vim/commit/e4c79d36150431ffb97cb8952ec482af2e57f228
Diffstat (limited to 'src/nvim/cmdexpand.c')
-rw-r--r--src/nvim/cmdexpand.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index 47c69ed6f8..610f2c4e0b 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -3479,7 +3479,6 @@ void wildmenu_cleanup(CmdlineInfo *cclp)
/// "getcompletion()" function
void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
- char *pat;
expand_T xpc;
bool filtered = false;
int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH
@@ -3510,9 +3509,10 @@ void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
const char *pattern = tv_get_string(&argvars[0]);
if (strcmp(type, "cmdline") == 0) {
- set_one_cmd_context(&xpc, pattern);
+ const int cmdline_len = (int)strlen(pattern);
+ set_cmd_context(&xpc, (char *)pattern, cmdline_len, cmdline_len, false);
xpc.xp_pattern_len = strlen(xpc.xp_pattern);
- xpc.xp_col = (int)strlen(pattern);
+ xpc.xp_col = cmdline_len;
goto theend;
}
@@ -3539,6 +3539,8 @@ void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
theend:
+ ;
+ char *pat;
if (cmdline_fuzzy_completion_supported(&xpc)) {
// when fuzzy matching, don't modify the search string
pat = xstrdup(xpc.xp_pattern);