@@ -7786,6 +7786,10 @@ next_search_hl(
77867786 }
77877787}
77887788
7789+ /*
7790+ * If there is a match fill "shl" and return one.
7791+ * Return zero otherwise.
7792+ */
77897793 static int
77907794next_search_hl_pos (
77917795 match_T * shl , /* points to a match */
@@ -7794,55 +7798,52 @@ next_search_hl_pos(
77947798 colnr_T mincol ) /* minimal column for a match */
77957799{
77967800 int i ;
7797- int bot = -1 ;
7801+ int found = -1 ;
77987802
7799- shl -> lnum = 0 ;
78007803 for (i = posmatch -> cur ; i < MAXPOSMATCH ; i ++ )
78017804 {
78027805 llpos_T * pos = & posmatch -> pos [i ];
78037806
78047807 if (pos -> lnum == 0 )
78057808 break ;
7806- if (pos -> col + pos -> len - 1 <= mincol )
7809+ if (pos -> len == 0 && pos -> col < mincol )
78077810 continue ;
78087811 if (pos -> lnum == lnum )
78097812 {
7810- if (shl -> lnum == lnum )
7813+ if (found >= 0 )
78117814 {
7812- /* partially sort positions by column numbers
7813- * on the same line */
7814- if (pos -> col < posmatch -> pos [bot ].col )
7815+ /* if this match comes before the one at "found" then swap
7816+ * them */
7817+ if (pos -> col < posmatch -> pos [found ].col )
78157818 {
78167819 llpos_T tmp = * pos ;
78177820
7818- * pos = posmatch -> pos [bot ];
7819- posmatch -> pos [bot ] = tmp ;
7821+ * pos = posmatch -> pos [found ];
7822+ posmatch -> pos [found ] = tmp ;
78207823 }
78217824 }
78227825 else
7823- {
7824- bot = i ;
7825- shl -> lnum = lnum ;
7826- }
7826+ found = i ;
78277827 }
78287828 }
78297829 posmatch -> cur = 0 ;
7830- if (shl -> lnum == lnum && bot >= 0 )
7830+ if (found >= 0 )
78317831 {
7832- colnr_T start = posmatch -> pos [bot ].col == 0
7833- ? 0 : posmatch -> pos [bot ].col - 1 ;
7834- colnr_T end = posmatch -> pos [bot ].col == 0
7835- ? MAXCOL : start + posmatch -> pos [bot ].len ;
7832+ colnr_T start = posmatch -> pos [found ].col == 0
7833+ ? 0 : posmatch -> pos [found ].col - 1 ;
7834+ colnr_T end = posmatch -> pos [found ].col == 0
7835+ ? MAXCOL : start + posmatch -> pos [found ].len ;
78367836
7837+ shl -> lnum = lnum ;
78377838 shl -> rm .startpos [0 ].lnum = 0 ;
78387839 shl -> rm .startpos [0 ].col = start ;
78397840 shl -> rm .endpos [0 ].lnum = 0 ;
78407841 shl -> rm .endpos [0 ].col = end ;
78417842 shl -> is_addpos = TRUE;
7842- posmatch -> cur = bot + 1 ;
7843- return TRUE ;
7843+ posmatch -> cur = found + 1 ;
7844+ return 1 ;
78447845 }
7845- return FALSE ;
7846+ return 0 ;
78467847}
78477848#endif
78487849
0 commit comments