summaryrefslogtreecommitdiffstats
path: root/src/cmdexpand.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-06-15 22:51:57 +0100
committerBram Moolenaar <Bram@vim.org>2023-06-15 22:51:57 +0100
commit094dd152fe1d47878ec6c0b3f54b03ffde7f4a2d (patch)
tree800ef9ce98fd3165531e4c8f03c241fc95dba760 /src/cmdexpand.c
parentda51ad51bf4fbd66619786d0e6a83fb3ca09930b (diff)
patch 9.0.1636: expanding a pattern interferes with cmdline completionv9.0.1636
Problem: Expanding a pattern interferes with command line completion. Solution: Set the file index only when appropriate. (closes #12519)
Diffstat (limited to 'src/cmdexpand.c')
-rw-r--r--src/cmdexpand.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index 46615383c0..09691066e0 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -957,7 +957,7 @@ ExpandOne(
int mode)
{
char_u *ss = NULL;
- static int findex;
+ static int findex; // TODO: Move into expand_T
static char_u *orig_save = NULL; // kept value of orig
int orig_saved = FALSE;
int i;
@@ -971,8 +971,9 @@ ExpandOne(
if (mode == WILD_CANCEL)
ss = vim_strsave(orig_save ? orig_save : (char_u *)"");
else if (mode == WILD_APPLY)
- ss = vim_strsave(findex == -1 ? (orig_save ?
- orig_save : (char_u *)"") : xp->xp_files[findex]);
+ ss = vim_strsave(findex == -1
+ ? (orig_save ? orig_save : (char_u *)"")
+ : xp->xp_files[findex]);
// free old names
if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
@@ -985,7 +986,9 @@ ExpandOne(
if (compl_match_array != NULL)
cmdline_pum_remove();
}
- findex = 0;
+ // TODO: Remove condition if "findex" is part of expand_T ?
+ if (mode != WILD_EXPAND_FREE && mode != WILD_ALL && mode != WILD_ALL_KEEP)
+ findex = 0;
if (mode == WILD_FREE) // only release file name
return NULL;