Patch 7.4.2217
Problem: When using matchaddpos() a character after the end of the line can
be highlighted.
Solution: Only highlight existing characters. (Hirohito Higashi)
Files: src/screen.c, src/structs.h, src/testdir/test_match.vim
*** ../vim-7.4.2216/src/screen.c 2016-08-14 19:54:16.328930182 +0200
--- src/screen.c 2016-08-16 15:53:04.921146911 +0200
***************
*** 3542,3547 ****
--- 3542,3548 ----
shl->startcol = MAXCOL;
shl->endcol = MAXCOL;
shl->attr_cur = 0;
+ shl->is_addpos = FALSE;
v = (long)(ptr - line);
if (cur != NULL)
cur->pos.cur = 0;
***************
*** 5125,5138 ****
* needed when a '$' was displayed for 'list'. */
#ifdef FEAT_SEARCH_EXTRA
prevcol_hl_flag = FALSE;
! if (prevcol == (long)search_hl.startcol)
prevcol_hl_flag = TRUE;
else
{
cur = wp->w_match_head;
while (cur != NULL)
{
! if (prevcol == (long)cur->hl.startcol)
{
prevcol_hl_flag = TRUE;
break;
--- 5126,5139 ----
* needed when a '$' was displayed for 'list'. */
#ifdef FEAT_SEARCH_EXTRA
prevcol_hl_flag = FALSE;
! if (!search_hl.is_addpos && prevcol == (long)search_hl.startcol)
prevcol_hl_flag = TRUE;
else
{
cur = wp->w_match_head;
while (cur != NULL)
{
! if (!cur->hl.is_addpos && prevcol == (long)cur->hl.startcol)
{
prevcol_hl_flag = TRUE;
break;
***************
*** 5207,5213 ****
}
else
shl = &cur->hl;
! if ((ptr - line) - 1 == (long)shl->startcol)
char_attr = shl->attr;
if (shl != &search_hl && cur != NULL)
cur = cur->next;
--- 5208,5215 ----
}
else
shl = &cur->hl;
! if ((ptr - line) - 1 == (long)shl->startcol
! && (shl == &search_hl || !shl->is_addpos))
char_attr = shl->attr;
if (shl != &search_hl && cur != NULL)
cur = cur->next;
***************
*** 7815,7820 ****
--- 7817,7823 ----
shl->rm.startpos[0].col = start;
shl->rm.endpos[0].lnum = 0;
shl->rm.endpos[0].col = end;
+ shl->is_addpos = TRUE;
posmatch->cur = bot + 1;
return TRUE;
}
*** ../vim-7.4.2216/src/structs.h 2016-08-12 18:29:36.614738284 +0200
--- src/structs.h 2016-08-16 15:53:04.925146874 +0200
***************
*** 2439,2444 ****
--- 2439,2446 ----
linenr_T first_lnum; /* first lnum to search for multi-line pat */
colnr_T startcol; /* in win_line() points to char where HL starts */
colnr_T endcol; /* in win_line() points to char where HL ends */
+ int is_addpos; /* position specified directly by
+ matchaddpos(). TRUE/FALSE */
#ifdef FEAT_RELTIME
proftime_T tm; /* for a time limit */
#endif
*** ../vim-7.4.2216/src/testdir/test_match.vim 2016-08-06 15:29:07.241549789
+0200
--- src/testdir/test_match.vim 2016-08-16 15:53:04.925146874 +0200
***************
*** 1,7 ****
" Test for :match, :2match, :3match, clearmatches(), getmatches(), matchadd(),
" matchaddpos(), matcharg(), matchdelete(), matchstrpos() and setmatches().
! function Test_matcharg()
highlight MyGroup1 term=bold ctermbg=red guibg=red
highlight MyGroup2 term=italic ctermbg=green guibg=green
highlight MyGroup3 term=underline ctermbg=blue guibg=blue
--- 1,7 ----
" Test for :match, :2match, :3match, clearmatches(), getmatches(), matchadd(),
" matchaddpos(), matcharg(), matchdelete(), matchstrpos() and setmatches().
! function Test_match()
highlight MyGroup1 term=bold ctermbg=red guibg=red
highlight MyGroup2 term=italic ctermbg=green guibg=green
highlight MyGroup3 term=underline ctermbg=blue guibg=blue
***************
*** 162,165 ****
--- 162,189 ----
call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing',
'execute'], 'img'))
endfunc
+ func Test_matchaddpos()
+ syntax on
+ set hlsearch
+
+ call setline(1, ['12345', 'NP'])
+ call matchaddpos('Error', [[1,2], [1,6], [2,2]])
+ redraw!
+ call assert_notequal(screenattr(2,2), 0)
+ call assert_equal(screenattr(2,2), screenattr(1,2))
+ call assert_notequal(screenattr(2,2), screenattr(1,6))
+ 1
+ call matchadd('Search', 'N\|\n')
+ redraw!
+ call assert_notequal(screenattr(2,1), 0)
+ call assert_equal(screenattr(2,1), screenattr(1,6))
+ exec "norm! i0\<Esc>"
+ redraw!
+ call assert_equal(screenattr(2,2), screenattr(1,6))
+
+ nohl
+ syntax off
+ set hlsearch&
+ endfunc
+
" vim: et ts=2 sw=2
*** ../vim-7.4.2216/src/version.c 2016-08-15 22:54:45.988943405 +0200
--- src/version.c 2016-08-16 15:52:04.253735719 +0200
***************
*** 765,766 ****
--- 765,768 ----
{ /* Add new patch number below this line */
+ /**/
+ 2217,
/**/
--
If Pacman had affected us as kids we'd be running around in dark rooms,
munching pills and listening to repetitive music.
-- Marcus Brigstocke
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.