mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.1.1112: Inconsistencies in get_next_or_prev_match() (#32447)
Problem: Inconsistencies in get_next_or_prev_match() (after 9.1.1109).
Solution: Change "file" to "entry" or "match" in comments. Use the same
order of branches for PAGEUP and PAGEDOWN (zeertzjq).
closes: vim/vim#16633
b6c900be9c
This commit is contained in:
parent
f20335a54c
commit
1cdeb037c1
@ -645,7 +645,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
|
|||||||
/// in "xp->xp_selected"
|
/// in "xp->xp_selected"
|
||||||
static char *get_next_or_prev_match(int mode, expand_T *xp)
|
static char *get_next_or_prev_match(int mode, expand_T *xp)
|
||||||
{
|
{
|
||||||
// When no files found, return NULL
|
// When no matches found, return NULL
|
||||||
if (xp->xp_numfiles <= 0) {
|
if (xp->xp_numfiles <= 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -653,14 +653,15 @@ static char *get_next_or_prev_match(int mode, expand_T *xp)
|
|||||||
int findex = xp->xp_selected;
|
int findex = xp->xp_selected;
|
||||||
|
|
||||||
if (mode == WILD_PREV) {
|
if (mode == WILD_PREV) {
|
||||||
// Select last file if at start
|
// Select the last entry if at original text
|
||||||
if (findex == -1) {
|
if (findex == -1) {
|
||||||
findex = xp->xp_numfiles;
|
findex = xp->xp_numfiles;
|
||||||
}
|
}
|
||||||
|
// Otherwise select the previous entry
|
||||||
findex--;
|
findex--;
|
||||||
} else if (mode == WILD_NEXT) {
|
} else if (mode == WILD_NEXT) {
|
||||||
// Select next file
|
// Select the next entry
|
||||||
findex = findex + 1;
|
findex++;
|
||||||
} else if (mode == WILD_PAGEUP || mode == WILD_PAGEDOWN) {
|
} else if (mode == WILD_PAGEUP || mode == WILD_PAGEDOWN) {
|
||||||
// Get the height of popup menu (used for both PAGEUP and PAGEDOWN)
|
// Get the height of popup menu (used for both PAGEUP and PAGEDOWN)
|
||||||
int ht = pum_get_height();
|
int ht = pum_get_height();
|
||||||
@ -672,7 +673,7 @@ static char *get_next_or_prev_match(int mode, expand_T *xp)
|
|||||||
if (findex == 0) {
|
if (findex == 0) {
|
||||||
// at the first entry, don't select any entries
|
// at the first entry, don't select any entries
|
||||||
findex = -1;
|
findex = -1;
|
||||||
} else if (findex == -1) {
|
} else if (findex < 0) {
|
||||||
// no entry is selected. select the last entry
|
// no entry is selected. select the last entry
|
||||||
findex = xp->xp_numfiles - 1;
|
findex = xp->xp_numfiles - 1;
|
||||||
} else {
|
} else {
|
||||||
@ -680,12 +681,12 @@ static char *get_next_or_prev_match(int mode, expand_T *xp)
|
|||||||
findex = MAX(findex - ht, 0);
|
findex = MAX(findex - ht, 0);
|
||||||
}
|
}
|
||||||
} else { // mode == WILD_PAGEDOWN
|
} else { // mode == WILD_PAGEDOWN
|
||||||
if (findex < 0) {
|
if (findex == xp->xp_numfiles - 1) {
|
||||||
// no entry is selected. select the first entry
|
|
||||||
findex = 0;
|
|
||||||
} else if (findex == xp->xp_numfiles - 1) {
|
|
||||||
// at the last entry, don't select any entries
|
// at the last entry, don't select any entries
|
||||||
findex = -1;
|
findex = -1;
|
||||||
|
} else if (findex < 0) {
|
||||||
|
// no entry is selected. select the first entry
|
||||||
|
findex = 0;
|
||||||
} else {
|
} else {
|
||||||
// go down by the pum height
|
// go down by the pum height
|
||||||
findex = MIN(findex + ht, xp->xp_numfiles - 1);
|
findex = MIN(findex + ht, xp->xp_numfiles - 1);
|
||||||
@ -698,7 +699,7 @@ static char *get_next_or_prev_match(int mode, expand_T *xp)
|
|||||||
|
|
||||||
// Handle wrapping around
|
// Handle wrapping around
|
||||||
if (findex < 0 || findex >= xp->xp_numfiles) {
|
if (findex < 0 || findex >= xp->xp_numfiles) {
|
||||||
// If original string exists, return to it when wrapping around
|
// If original text exists, return to it when wrapping around
|
||||||
if (xp->xp_orig != NULL) {
|
if (xp->xp_orig != NULL) {
|
||||||
findex = -1;
|
findex = -1;
|
||||||
} else {
|
} else {
|
||||||
@ -716,7 +717,7 @@ static char *get_next_or_prev_match(int mode, expand_T *xp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
xp->xp_selected = findex;
|
xp->xp_selected = findex;
|
||||||
// Return the original string or the selected match
|
// Return the original text or the selected match
|
||||||
return xstrdup(findex == -1 ? xp->xp_orig : xp->xp_files[findex]);
|
return xstrdup(findex == -1 ? xp->xp_orig : xp->xp_files[findex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user