diff src/screen.c @ 9885:4e8b05fa12c6 v7.4.2217

commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 16 16:08:18 2016 +0200 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)
author Christian Brabandt <cb@256bit.org>
date Tue, 16 Aug 2016 16:15:06 +0200
parents 7da89d9c744b
children ccb6461b82df
line wrap: on
line diff
--- a/src/screen.c
+++ b/src/screen.c
@@ -3542,6 +3542,7 @@ win_line(
 	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 @@ win_line(
 	     * 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 @@ win_line(
 			}
 			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 @@ next_search_hl_pos(
 	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;
     }