summaryrefslogtreecommitdiffstats
path: root/src/cmdexpand.c
diff options
context:
space:
mode:
authorii14 <ii14@users.noreply.github.com>2021-11-21 12:13:56 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-21 12:13:56 +0000
commit4785fe02bba14c4e0aede0fa425ca790a1cb98d7 (patch)
tree9619c22915e44234cc765cc34074bc53798cbaed /src/cmdexpand.c
parent923dce2b07ff185c0ef661f3eca47bc17655f01b (diff)
patch 8.2.3638: getcompletion() always passes zero as positionv8.2.3638
Problem: getcompletion() always passes zero as position to custom completion function. Solution: Pass the pattern length. (closes #9173)
Diffstat (limited to 'src/cmdexpand.c')
-rw-r--r--src/cmdexpand.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index 71c4f690cb..9e88d99b7a 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -2900,6 +2900,7 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
|| check_for_opt_bool_arg(argvars, 2) == FAIL))
return;
+ pat = tv_get_string(&argvars[0]);
if (argvars[1].v_type != VAR_STRING)
{
semsg(_(e_invarg2), "type must be a string");
@@ -2920,12 +2921,13 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
ExpandInit(&xpc);
if (STRCMP(type, "cmdline") == 0)
{
- set_one_cmd_context(&xpc, tv_get_string(&argvars[0]));
+ set_one_cmd_context(&xpc, pat);
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
+ xpc.xp_col = (int)STRLEN(pat);
}
else
{
- xpc.xp_pattern = tv_get_string(&argvars[0]);
+ xpc.xp_pattern = pat;
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
xpc.xp_context = cmdcomplete_str_to_type(type);