]> granicus.if.org Git - vim/commitdiff
patch 8.0.0033 v8.0.0033
authorBram Moolenaar <Bram@vim.org>
Sat, 15 Oct 2016 12:56:30 +0000 (14:56 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 15 Oct 2016 12:56:30 +0000 (14:56 +0200)
Problem:    Cannot use overlapping positions with matchaddpos().
Solution:   Check end of match. (Ozaki Kiichi) Add a test (Hirohito Higashi)

src/screen.c
src/testdir/test_match.vim
src/version.c

index 5ebca09804aa16e5b9c5bec2770dbd224acce4df..0889db91d61cbbae6355d99d48c936582f55f59d 100644 (file)
@@ -7786,21 +7786,23 @@ next_search_hl_pos(
     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;
                }
            }
index 9ac1db157f9986dc85f85fe3121390e620e679ec..3b20d5d439021e09af6fef9027c7fac1931d77d2 100644 (file)
@@ -181,6 +181,16 @@ func Test_matchaddpos()
   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&
index 6fee4abf730f98177d105e4c6681a531e0956b7f..b2066e4e84147d704ded8fe9f6bd9104eb0d6c5c 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    33,
 /**/
     32,
 /**/