patch 8.0.0033
Problem: Cannot use overlapping positions with matchaddpos().
Solution: Check end of match. (Ozaki Kiichi) Add a test (Hirohito Higashi)
diff --git a/src/screen.c b/src/screen.c
index 5ebca09..0889db9 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -7786,21 +7786,23 @@
shl->lnum = 0;
for (i = posmatch->cur; i < MAXPOSMATCH; i++)
{
- if (posmatch->pos[i].lnum == 0)
+ llpos_T *pos = &posmatch->pos[i];
+
+ if (pos->lnum == 0)
break;
- if (posmatch->pos[i].col < mincol)
+ if (pos->col + pos->len - 1 <= mincol)
continue;
- if (posmatch->pos[i].lnum == lnum)
+ if (pos->lnum == lnum)
{
if (shl->lnum == lnum)
{
/* partially sort positions by column numbers
* on the same line */
- if (posmatch->pos[i].col < posmatch->pos[bot].col)
+ if (pos->col < posmatch->pos[bot].col)
{
- llpos_T tmp = posmatch->pos[i];
+ llpos_T tmp = *pos;
- posmatch->pos[i] = posmatch->pos[bot];
+ *pos = posmatch->pos[bot];
posmatch->pos[bot] = tmp;
}
}
diff --git a/src/testdir/test_match.vim b/src/testdir/test_match.vim
index 9ac1db1..3b20d5d 100644
--- a/src/testdir/test_match.vim
+++ b/src/testdir/test_match.vim
@@ -181,6 +181,16 @@
redraw!
call assert_equal(screenattr(2,2), screenattr(1,6))
+ " Check overlapping pos
+ call clearmatches()
+ call setline(1, ['1234567890', 'NH'])
+ call matchaddpos('Error', [[1,1,5], [1,3,5], [2,2]])
+ redraw!
+ call assert_notequal(screenattr(2,2), 0)
+ call assert_equal(screenattr(2,2), screenattr(1,5))
+ call assert_equal(screenattr(2,2), screenattr(1,7))
+ call assert_notequal(screenattr(2,2), screenattr(1,8))
+
nohl
syntax off
set hlsearch&
diff --git a/src/version.c b/src/version.c
index 6fee4ab..b2066e4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 33,
+/**/
32,
/**/
31,