aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-18 07:23:43 +0800
committerGitHub <noreply@github.com>2023-08-18 07:23:43 +0800
commit1d6c4ad073ecff42a4421c7b30b42937809bd248 (patch)
tree15d6541eeddbbcd975cf0b9a7e8c8c299fca1f96
parent19d7fb8efeaeb84bc639282de1510b7e8962d49a (diff)
downloadrneovim-1d6c4ad073ecff42a4421c7b30b42937809bd248.tar.gz
rneovim-1d6c4ad073ecff42a4421c7b30b42937809bd248.tar.bz2
rneovim-1d6c4ad073ecff42a4421c7b30b42937809bd248.zip
vim-patch:9.0.1735: Rename completion specific findex var (#24769)
Problem: Rename completion specific findex var Solution: Move "findex" static variable to xp_selected in expand_T closes: vim/vim#12548 https://github.com/vim/vim/commit/e9ef347c137aca6c2592beb19da45a8aece65e11
-rw-r--r--src/nvim/cmdexpand.c22
-rw-r--r--src/nvim/ex_cmds_defs.h1
2 files changed, 10 insertions, 13 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index 610f2c4e0b..eb9394c8ff 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -616,14 +616,14 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
}
/// Get the next or prev cmdline completion match. The index of the match is set
-/// in "p_findex"
-static char *get_next_or_prev_match(int mode, expand_T *xp, int *p_findex, char *orig_save)
+/// in "xp->xp_selected"
+static char *get_next_or_prev_match(int mode, expand_T *xp, char *orig_save)
{
if (xp->xp_numfiles <= 0) {
return NULL;
}
- int findex = *p_findex;
+ int findex = xp->xp_selected;
if (mode == WILD_PREV) {
if (findex == -1) {
@@ -696,7 +696,7 @@ static char *get_next_or_prev_match(int mode, expand_T *xp, int *p_findex, char
} else if (p_wmnu) {
redraw_wildmenu(xp, xp->xp_numfiles, xp->xp_files, findex, cmd_showtail);
}
- *p_findex = findex;
+ xp->xp_selected = findex;
return xstrdup(findex == -1 ? orig_save : xp->xp_files[findex]);
}
@@ -841,7 +841,6 @@ static char *find_longest_match(expand_T *xp, int options)
char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
{
char *ss = NULL;
- static int findex; // TODO(vim): Move into expand_T
static char *orig_save = NULL; // kept value of orig
int orig_saved = false;
@@ -849,15 +848,15 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
if (mode == WILD_NEXT || mode == WILD_PREV
|| mode == WILD_PAGEUP || mode == WILD_PAGEDOWN
|| mode == WILD_PUM_WANT) {
- return get_next_or_prev_match(mode, xp, &findex, orig_save);
+ return get_next_or_prev_match(mode, xp, orig_save);
}
if (mode == WILD_CANCEL) {
ss = xstrdup(orig_save ? orig_save : "");
} else if (mode == WILD_APPLY) {
- ss = xstrdup(findex == -1
+ ss = xstrdup(xp->xp_selected == -1
? (orig_save ? orig_save : "")
- : xp->xp_files[findex]);
+ : xp->xp_files[xp->xp_selected]);
}
// free old names
@@ -871,10 +870,7 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
cmdline_pum_remove();
}
}
- // TODO(vim): Remove condition if "findex" is part of expand_T ?
- if (mode != WILD_EXPAND_FREE && mode != WILD_ALL && mode != WILD_ALL_KEEP) {
- findex = 0;
- }
+ xp->xp_selected = 0;
if (mode == WILD_FREE) { // only release file name
return NULL;
@@ -891,7 +887,7 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
// Find longest common part
if (mode == WILD_LONGEST && xp->xp_numfiles > 0) {
ss = find_longest_match(xp, options);
- findex = -1; // next p_wc gets first one
+ xp->xp_selected = -1; // next p_wc gets first one
}
// Concatenate all matching names. Unless interrupted, this can be slow
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index 568d4d38ba..d07532dc11 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -244,6 +244,7 @@ struct expand {
#endif
int xp_numfiles; // number of files found by file name completion
int xp_col; // cursor position in line
+ int xp_selected; // selected index in completion
char **xp_files; // list of files
char *xp_line; // text being completed
#define EXPAND_BUF_LEN 256