Hi Bram and list,

2016-10-15(Sat) 21:57:02 UTC+9 Bram Moolenaar:
> Patch 8.0.0033
> Problem:    Cannot use overlapping positions with matchaddpos().
> Solution:   Check end of match. (Ozaki Kiichi) Add a test (Hirohito Higashi)
> Files:      src/screen.c, src/testdir/test_match.vim
> 
> 
> *** ../vim-8.0.0032/src/screen.c      2016-10-02 23:09:27.643153731 +0200
> --- src/screen.c      2016-10-15 14:52:51.297854046 +0200
> ***************
> *** 7786,7806 ****
>       shl->lnum = 0;
>       for (i = posmatch->cur; i < MAXPOSMATCH; i++)
>       {
> !     if (posmatch->pos[i].lnum == 0)
>           break;
> !     if (posmatch->pos[i].col < mincol)
>           continue;
> !     if (posmatch->pos[i].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)
>               {
> !                 llpos_T     tmp = posmatch->pos[i];
>   
> !                 posmatch->pos[i] = posmatch->pos[bot];
>                   posmatch->pos[bot] = tmp;
>               }
>           }
> --- 7786,7808 ----
>       shl->lnum = 0;
>       for (i = posmatch->cur; i < MAXPOSMATCH; i++)
>       {
> !     llpos_T *pos = &posmatch->pos[i];
> ! 
> !     if (pos->lnum == 0)
>           break;
> !     if (pos->col + pos->len - 1 <= mincol)
>           continue;
> !     if (pos->lnum == lnum)
>       {
>           if (shl->lnum == lnum)
>           {
>               /* partially sort positions by column numbers
>                * on the same line */
> !             if (pos->col < posmatch->pos[bot].col)
>               {
> !                 llpos_T     tmp = *pos;
>   
> !                 *pos = posmatch->pos[bot];
>                   posmatch->pos[bot] = tmp;
>               }
>           }
> *** ../vim-8.0.0032/src/testdir/test_match.vim        2016-08-27 
> 18:28:13.000000000 +0200
> --- src/testdir/test_match.vim        2016-10-15 14:50:58.442694482 +0200
> ***************
> *** 181,186 ****
> --- 181,196 ----
>     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&
> *** ../vim-8.0.0032/src/version.c     2016-10-12 17:52:39.199701825 +0200
> --- src/version.c     2016-10-15 14:54:57.816912413 +0200
> ***************
> *** 766,767 ****
> --- 766,769 ----
>   {   /* Add new patch number below this line */
> + /**/
> +     33,
>   /**/

Regression occurred.
When {pos} item specified a number (line number), this line is not highlighted 
properly.

:call matchaddpos('Error', [[1]])

I made a pacth that contains a test.
Please check this.
--
Best regards,
Hirohito Higashi (a.k.a. h_east)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/screen.c b/src/screen.c
index 0889db9..2fd1a52 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -7790,7 +7790,7 @@ next_search_hl_pos(
 
 	if (pos->lnum == 0)
 	    break;
-	if (pos->col + pos->len - 1 <= mincol)
+	if (pos->len == 0 && pos->col < mincol)
 	    continue;
 	if (pos->lnum == lnum)
 	{
diff --git a/src/testdir/test_match.vim b/src/testdir/test_match.vim
index 3b20d5d..9398ef2 100644
--- a/src/testdir/test_match.vim
+++ b/src/testdir/test_match.vim
@@ -191,7 +191,15 @@ func Test_matchaddpos()
   call assert_equal(screenattr(2,2), screenattr(1,7))
   call assert_notequal(screenattr(2,2), screenattr(1,8))
 
+  call clearmatches()
+  call matchaddpos('Error', [[1], [2,2]])
+  redraw!
+  call assert_equal(screenattr(2,2), screenattr(1,1))
+  call assert_equal(screenattr(2,2), screenattr(1,10))
+  call assert_notequal(screenattr(2,2), screenattr(1,11))
+
   nohl
+  call clearmatches()
   syntax off
   set hlsearch&
 endfunc

Raspunde prin e-mail lui