nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 7ef5c532633d1896115a7e7b98d7a5fb55385098
parent 6bd94040dff1a7120a19155f8caa5b6d1f814b1a
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sun, 12 Feb 2017 22:34:31 +0100

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.

Diffstat:
Msrc/color.c | 10+++++++++-
Msrc/nano.h | 2++
Msrc/winio.c | 8++++++--
3 files changed, 17 insertions(+), 3 deletions(-)

diff --git 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 @@ -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 @@ -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);