Skip to content

Commit b6c900b

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.1112: Inconsistencies in get_next_or_prev_match()
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: #16633 Signed-off-by: zeertzjq <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent faf4112 commit b6c900b

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/cmdexpand.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -737,21 +737,22 @@ get_next_or_prev_match(int mode, expand_T *xp)
737737
int findex = xp->xp_selected;
738738
int ht;
739739

740-
// When no files found, return NULL
740+
// When no matches found, return NULL
741741
if (xp->xp_numfiles <= 0)
742742
return NULL;
743743

744744
if (mode == WILD_PREV)
745745
{
746-
// Select last file if at start
746+
// Select the last entry if at original text
747747
if (findex == -1)
748748
findex = xp->xp_numfiles;
749+
// Otherwise select the previous entry
749750
--findex;
750751
}
751752
else if (mode == WILD_NEXT)
752753
{
753-
// Select next file
754-
findex = findex + 1;
754+
// Select the next entry
755+
++findex;
755756
}
756757
else // WILD_PAGEDOWN or WILD_PAGEUP
757758
{
@@ -765,7 +766,7 @@ get_next_or_prev_match(int mode, expand_T *xp)
765766
if (findex == 0)
766767
// at the first entry, don't select any entries
767768
findex = -1;
768-
else if (findex == -1)
769+
else if (findex < 0)
769770
// no entry is selected. select the last entry
770771
findex = xp->xp_numfiles - 1;
771772
else
@@ -774,12 +775,12 @@ get_next_or_prev_match(int mode, expand_T *xp)
774775
}
775776
else // mode == WILD_PAGEDOWN
776777
{
777-
if (findex < 0)
778-
// no entry is selected, select the first entry
779-
findex = 0;
780-
else if (findex >= xp->xp_numfiles - 1)
778+
if (findex >= xp->xp_numfiles - 1)
781779
// at the last entry, don't select any entries
782780
findex = -1;
781+
else if (findex < 0)
782+
// no entry is selected, select the first entry
783+
findex = 0;
783784
else
784785
// go down by the pum height
785786
findex = MIN(findex + ht, xp->xp_numfiles - 1);
@@ -789,7 +790,7 @@ get_next_or_prev_match(int mode, expand_T *xp)
789790
// Handle wrapping around
790791
if (findex < 0 || findex >= xp->xp_numfiles)
791792
{
792-
// If original string exists, return to it when wrapping around
793+
// If original text exists, return to it when wrapping around
793794
if (xp->xp_orig != NULL)
794795
findex = -1;
795796
else
@@ -808,7 +809,7 @@ get_next_or_prev_match(int mode, expand_T *xp)
808809
cmd_showtail);
809810

810811
xp->xp_selected = findex;
811-
// Return the original string or the selected match
812+
// Return the original text or the selected match
812813
return vim_strsave(findex == -1 ? xp->xp_orig : xp->xp_files[findex]);
813814
}
814815

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1112,
707709
/**/
708710
1111,
709711
/**/

0 commit comments

Comments
 (0)