mirror of
https://github.com/vim/vim.git
synced 2025-09-07 22:03:36 -04:00
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)
This commit is contained in:
parent
22177f0c08
commit
4f416e4124
@ -3542,6 +3542,7 @@ win_line(
|
|||||||
shl->startcol = MAXCOL;
|
shl->startcol = MAXCOL;
|
||||||
shl->endcol = MAXCOL;
|
shl->endcol = MAXCOL;
|
||||||
shl->attr_cur = 0;
|
shl->attr_cur = 0;
|
||||||
|
shl->is_addpos = FALSE;
|
||||||
v = (long)(ptr - line);
|
v = (long)(ptr - line);
|
||||||
if (cur != NULL)
|
if (cur != NULL)
|
||||||
cur->pos.cur = 0;
|
cur->pos.cur = 0;
|
||||||
@ -5125,14 +5126,14 @@ win_line(
|
|||||||
* needed when a '$' was displayed for 'list'. */
|
* needed when a '$' was displayed for 'list'. */
|
||||||
#ifdef FEAT_SEARCH_EXTRA
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
prevcol_hl_flag = FALSE;
|
prevcol_hl_flag = FALSE;
|
||||||
if (prevcol == (long)search_hl.startcol)
|
if (!search_hl.is_addpos && prevcol == (long)search_hl.startcol)
|
||||||
prevcol_hl_flag = TRUE;
|
prevcol_hl_flag = TRUE;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cur = wp->w_match_head;
|
cur = wp->w_match_head;
|
||||||
while (cur != NULL)
|
while (cur != NULL)
|
||||||
{
|
{
|
||||||
if (prevcol == (long)cur->hl.startcol)
|
if (!cur->hl.is_addpos && prevcol == (long)cur->hl.startcol)
|
||||||
{
|
{
|
||||||
prevcol_hl_flag = TRUE;
|
prevcol_hl_flag = TRUE;
|
||||||
break;
|
break;
|
||||||
@ -5207,7 +5208,8 @@ win_line(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
shl = &cur->hl;
|
shl = &cur->hl;
|
||||||
if ((ptr - line) - 1 == (long)shl->startcol)
|
if ((ptr - line) - 1 == (long)shl->startcol
|
||||||
|
&& (shl == &search_hl || !shl->is_addpos))
|
||||||
char_attr = shl->attr;
|
char_attr = shl->attr;
|
||||||
if (shl != &search_hl && cur != NULL)
|
if (shl != &search_hl && cur != NULL)
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
@ -7815,6 +7817,7 @@ next_search_hl_pos(
|
|||||||
shl->rm.startpos[0].col = start;
|
shl->rm.startpos[0].col = start;
|
||||||
shl->rm.endpos[0].lnum = 0;
|
shl->rm.endpos[0].lnum = 0;
|
||||||
shl->rm.endpos[0].col = end;
|
shl->rm.endpos[0].col = end;
|
||||||
|
shl->is_addpos = TRUE;
|
||||||
posmatch->cur = bot + 1;
|
posmatch->cur = bot + 1;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2439,6 +2439,8 @@ typedef struct
|
|||||||
linenr_T first_lnum; /* first lnum to search for multi-line pat */
|
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 startcol; /* in win_line() points to char where HL starts */
|
||||||
colnr_T endcol; /* in win_line() points to char where HL ends */
|
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
|
#ifdef FEAT_RELTIME
|
||||||
proftime_T tm; /* for a time limit */
|
proftime_T tm; /* for a time limit */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
" Test for :match, :2match, :3match, clearmatches(), getmatches(), matchadd(),
|
" Test for :match, :2match, :3match, clearmatches(), getmatches(), matchadd(),
|
||||||
" matchaddpos(), matcharg(), matchdelete(), matchstrpos() and setmatches().
|
" matchaddpos(), matcharg(), matchdelete(), matchstrpos() and setmatches().
|
||||||
|
|
||||||
function Test_matcharg()
|
function Test_match()
|
||||||
highlight MyGroup1 term=bold ctermbg=red guibg=red
|
highlight MyGroup1 term=bold ctermbg=red guibg=red
|
||||||
highlight MyGroup2 term=italic ctermbg=green guibg=green
|
highlight MyGroup2 term=italic ctermbg=green guibg=green
|
||||||
highlight MyGroup3 term=underline ctermbg=blue guibg=blue
|
highlight MyGroup3 term=underline ctermbg=blue guibg=blue
|
||||||
@ -162,4 +162,28 @@ func Test_matchstrpos()
|
|||||||
call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing', 'execute'], 'img'))
|
call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing', 'execute'], 'img'))
|
||||||
endfunc
|
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: et ts=2 sw=2
|
||||||
|
@ -763,6 +763,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2217,
|
||||||
/**/
|
/**/
|
||||||
2216,
|
2216,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user