Patch 8.0.0033

43 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 15, 2016, 8:57:02 AM10/15/16
to vim...@googlegroups.com

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,
/**/

--
Q: Why does /dev/null accept only integers?
A: You can't sink a float.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

h_east

unread,
Oct 16, 2016, 7:22:19 AM10/16/16
to vim_dev
Hi Bram and list,

2016-10-15(Sat) 21:57:02 UTC+9 Bram Moolenaar:

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)

fix_matchaddpos_2.patch

Bram Moolenaar

unread,
Oct 16, 2016, 8:36:29 AM10/16/16
to h_east, vim_dev

Hirohito Higashi wrote:

> 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
>
> [...]
>
> 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.

Thanks. That code is quite confusing. The function returns TRUE or
FALSE but the caller checks for 1 or 0. I'll clean it up a bit.

Perhaps we need some more tests for this.

--
Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke
Any sufficiently advanced bug is indistinguishable from a feature.
Rich Kulawiec
Reply all
Reply to author
Forward
0 new messages