From 7e04fea92b671aa5a80aa36210f032392b0fbf8e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 5 Feb 2021 16:05:38 +0100 Subject: [PATCH] painting: when finding an end match, set its multidata right away When leaving the multidata unset (as was done until now) and the end match is offscreen, then this could lead to miscolorings later when jumping over this end match instead of scrolling past it. This fixes https://savannah.gnu.org/bugs/?60012. Bug existed since before version 2.1.10. --- src/winio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/winio.c b/src/winio.c index a70d9004..ff5e5a3a 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2500,7 +2500,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col) /* The match positions of a single-line regex. */ const linestruct *start_line = line->prev; /* The first line before line that matches 'start'. */ - const linestruct *end_line = line; + linestruct *end_line = line; /* The line that matches 'end'. */ regmatch_t startmatch, endmatch; /* The match positions of the start and end regexes. */ @@ -2720,7 +2720,16 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col) wattron(edit, varnish->attributes); mvwaddnstr(edit, row, margin + start_col, thetext, -1); wattroff(edit, varnish->attributes); + line->multidata[varnish->id] = STARTSHERE; + + if (end_line->multidata == NULL) { + end_line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short)); + for (short item = 0; item < openfile->syntax->nmultis; item++) + end_line->multidata[item] = 0; + } + end_line->multidata[varnish->id] = ENDSHERE; + break; } }