diff --git a/src/color.c b/src/color.c index 97a9d0404bf603e00a5417e3d304bcd1ed63918c..5bff6806fc15c12f0b82ce3ccf7cdb29ca5c7ddd 100644 --- a/src/color.c +++ b/src/color.c @@ -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. */ diff --git a/src/nano.h b/src/nano.h index 91e4a0541b0b7744b5ad1f67c59ff39d29dcd7d6..964f96d4994f47ff356e773cdd86bd42454a1474 100644 --- a/src/nano.h +++ b/src/nano.h @@ -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. */ diff --git a/src/winio.c b/src/winio.c index e1e8f886f85fc6339549822906a4e82df208420b..32e8985e9ed01c1bddbdd9a8a67d25125c3763b6 100644 --- a/src/winio.c +++ b/src/winio.c @@ -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);