Skip to content

Commit a6c27ee

Browse files
committed
patch 8.0.0033
Problem: Cannot use overlapping positions with matchaddpos(). Solution: Check end of match. (Ozaki Kiichi) Add a test (Hirohito Higashi)
1 parent 4575876 commit a6c27ee

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/screen.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7786,21 +7786,23 @@ next_search_hl_pos(
77867786
shl->lnum = 0;
77877787
for (i = posmatch->cur; i < MAXPOSMATCH; i++)
77887788
{
7789-
if (posmatch->pos[i].lnum == 0)
7789+
llpos_T *pos = &posmatch->pos[i];
7790+
7791+
if (pos->lnum == 0)
77907792
break;
7791-
if (posmatch->pos[i].col < mincol)
7793+
if (pos->col + pos->len - 1 <= mincol)
77927794
continue;
7793-
if (posmatch->pos[i].lnum == lnum)
7795+
if (pos->lnum == lnum)
77947796
{
77957797
if (shl->lnum == lnum)
77967798
{
77977799
/* partially sort positions by column numbers
77987800
* on the same line */
7799-
if (posmatch->pos[i].col < posmatch->pos[bot].col)
7801+
if (pos->col < posmatch->pos[bot].col)
78007802
{
7801-
llpos_T tmp = posmatch->pos[i];
7803+
llpos_T tmp = *pos;
78027804

7803-
posmatch->pos[i] = posmatch->pos[bot];
7805+
*pos = posmatch->pos[bot];
78047806
posmatch->pos[bot] = tmp;
78057807
}
78067808
}

src/testdir/test_match.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ func Test_matchaddpos()
181181
redraw!
182182
call assert_equal(screenattr(2,2), screenattr(1,6))
183183

184+
" Check overlapping pos
185+
call clearmatches()
186+
call setline(1, ['1234567890', 'NH'])
187+
call matchaddpos('Error', [[1,1,5], [1,3,5], [2,2]])
188+
redraw!
189+
call assert_notequal(screenattr(2,2), 0)
190+
call assert_equal(screenattr(2,2), screenattr(1,5))
191+
call assert_equal(screenattr(2,2), screenattr(1,7))
192+
call assert_notequal(screenattr(2,2), screenattr(1,8))
193+
184194
nohl
185195
syntax off
186196
set hlsearch&

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
33,
767769
/**/
768770
32,
769771
/**/

0 commit comments

Comments
 (0)