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)
diff --git a/src/screen.c b/src/screen.c
index f0587e3..64e159a 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -3542,6 +3542,7 @@
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,14 +5126,14 @@
* needed when a '$' was displayed for 'list'. */
#ifdef FEAT_SEARCH_EXTRA
prevcol_hl_flag = FALSE;
- if (prevcol == (long)search_hl.startcol)
+ if (!search_hl.is_addpos && prevcol == (long)search_hl.startcol)
prevcol_hl_flag = TRUE;
else
{
cur = wp->w_match_head;
while (cur != NULL)
{
- if (prevcol == (long)cur->hl.startcol)
+ if (!cur->hl.is_addpos && prevcol == (long)cur->hl.startcol)
{
prevcol_hl_flag = TRUE;
break;
@@ -5207,7 +5208,8 @@
}
else
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;
if (shl != &search_hl && cur != NULL)
cur = cur->next;
@@ -7815,6 +7817,7 @@
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;
}