@@ -7773,6 +7773,10 @@ next_search_hl(
77737773 }
77747774}
77757775
7776+ /*
7777+ * If there is a match fill "shl" and return one.
7778+ * Return zero otherwise.
7779+ */
77767780 static int
77777781next_search_hl_pos (
77787782 match_T * shl , /* points to a match */
@@ -7781,55 +7785,52 @@ next_search_hl_pos(
77817785 colnr_T mincol ) /* minimal column for a match */
77827786{
77837787 int i ;
7784- int bot = -1 ;
7788+ int found = -1 ;
77857789
7786- shl -> lnum = 0 ;
77877790 for (i = posmatch -> cur ; i < MAXPOSMATCH ; i ++ )
77887791 {
77897792 llpos_T * pos = & posmatch -> pos [i ];
77907793
77917794 if (pos -> lnum == 0 )
77927795 break ;
7793- if (pos -> col + pos -> len - 1 <= mincol )
7796+ if (pos -> len == 0 && pos -> col < mincol )
77947797 continue ;
77957798 if (pos -> lnum == lnum )
77967799 {
7797- if (shl -> lnum == lnum )
7800+ if (found >= 0 )
77987801 {
7799- /* partially sort positions by column numbers
7800- * on the same line */
7801- if (pos -> col < posmatch -> pos [bot ].col )
7802+ /* if this match comes before the one at "found" then swap
7803+ * them */
7804+ if (pos -> col < posmatch -> pos [found ].col )
78027805 {
78037806 llpos_T tmp = * pos ;
78047807
7805- * pos = posmatch -> pos [bot ];
7806- posmatch -> pos [bot ] = tmp ;
7808+ * pos = posmatch -> pos [found ];
7809+ posmatch -> pos [found ] = tmp ;
78077810 }
78087811 }
78097812 else
7810- {
7811- bot = i ;
7812- shl -> lnum = lnum ;
7813- }
7813+ found = i ;
78147814 }
78157815 }
78167816 posmatch -> cur = 0 ;
7817- if (shl -> lnum == lnum && bot >= 0 )
7817+ if (found >= 0 )
78187818 {
7819- colnr_T start = posmatch -> pos [bot ].col == 0
7820- ? 0 : posmatch -> pos [bot ].col - 1 ;
7821- colnr_T end = posmatch -> pos [bot ].col == 0
7822- ? MAXCOL : start + posmatch -> pos [bot ].len ;
7819+ colnr_T start = posmatch -> pos [found ].col == 0
7820+ ? 0 : posmatch -> pos [found ].col - 1 ;
7821+ colnr_T end = posmatch -> pos [found ].col == 0
7822+ ? MAXCOL : start + posmatch -> pos [found ].len ;
78237823
7824+ shl -> lnum = lnum ;
78247825 shl -> rm .startpos [0 ].lnum = 0 ;
78257826 shl -> rm .startpos [0 ].col = start ;
78267827 shl -> rm .endpos [0 ].lnum = 0 ;
78277828 shl -> rm .endpos [0 ].col = end ;
78287829 shl -> is_addpos = TRUE;
7829- posmatch -> cur = bot + 1 ;
7830- return TRUE ;
7830+ posmatch -> cur = found + 1 ;
7831+ return 1 ;
78317832 }
7832- return FALSE ;
7833+ return 0 ;
78337834}
78347835#endif
78357836
0 commit comments