painting: mark an unpaired start match as CWOULDBE

The lines that come after an unpaired start have to know about this.

This fixes https://savannah.gnu.org/bugs/?50293.
This commit is contained in:
Benno Schulenberg 2017-02-12 22:34:31 +01:00
parent 6bd94040df
commit 7ef5c53263
3 changed files with 17 additions and 3 deletions

View File

@ -423,6 +423,12 @@ void precalc_multicolorinfo(void)
/* Assume nothing applies until proven otherwise below. */
line->multidata[ink->id] = CNONE;
/* For an unpaired start match, mark all remaining lines. */
if (line->prev && line->prev->multidata[ink->id] == CWOULDBE) {
line->multidata[ink->id] = CWOULDBE;
continue;
}
/* When the line contains a start match, look for an end, and if
* found, mark all the lines that are affected. */
while (regexec(ink->start, line->data + index, 1,
@ -456,8 +462,10 @@ void precalc_multicolorinfo(void)
tailline = tailline->next;
}
if (tailline == NULL)
if (tailline == NULL) {
line->multidata[ink->id] = CWOULDBE;
break;
}
/* We found it, we found it, la la la la la. Mark all
* the lines in between and the end properly. */

View File

@ -288,6 +288,8 @@ typedef struct lintstruct {
/* Whole line engulfed by the regex, start < me, end > me. */
#define CSTARTENDHERE (1<<5)
/* Regex starts and ends within this line. */
#define CWOULDBE (1<<6)
/* An unpaired start match on or before this line. */
#endif /* !DISABLE_COLOR */
/* More structure types. */

View File

@ -2506,8 +2506,10 @@ void edit_draw(filestruct *fileptr, const char *converted,
end_line = end_line->next;
/* If there is no end, there is nothing to paint. */
if (end_line == NULL)
if (end_line == NULL) {
fileptr->multidata[varnish->id] = CWOULDBE;
goto tail_of_loop;
}
/* If the end is on a later line, paint whole line, and be done. */
if (end_line != fileptr) {
@ -2589,8 +2591,10 @@ void edit_draw(filestruct *fileptr, const char *converted,
end_line = end_line->next;
/* If there is no end, we're done with this regex. */
if (end_line == NULL)
if (end_line == NULL) {
fileptr->multidata[varnish->id] = CWOULDBE;
break;
}
/* Paint the rest of the line. */
mvwaddnstr(edit, row, margin + start_col, thetext, -1);