diff -u nano-35/winio.c nano-36/winio.c --- nano-35/winio.c Tue Sep 10 12:01:30 2002 +++ nano-36/winio.c Tue Sep 10 11:59:19 2002 @@ -782,23 +782,25 @@ } if (!regexec(&end_regexp, fileptr->data + startmatch.rm_eo, 1, &endmatch, - startmatch.rm_eo == 0 ? 0 : REG_NOTBOL) - && startmatch.rm_eo + endmatch.rm_eo > start - && startmatch.rm_eo + endmatch.rm_eo > startmatch.rm_so) { - /* There is an end on this line. Paint it. */ - - /* Translate the end match too */ + startmatch.rm_eo == 0 ? 0 : REG_NOTBOL)) { + /* Translate the end match to be relative to the + beginning of the line. */ endmatch.rm_so += startmatch.rm_eo; endmatch.rm_eo += startmatch.rm_eo; + /* There is an end on this line. But does it + appear on this page, and is the match more than + zero characters long? */ + if (endmatch.rm_eo > start && + endmatch.rm_eo > startmatch.rm_so) { + paintlen = endmatch.rm_eo - start - x_start; + if (x_start + paintlen > COLS) + paintlen = COLS - x_start; - paintlen = endmatch.rm_eo - start - x_start; - if (x_start + paintlen > COLS) - paintlen = COLS - x_start; - - assert(0 <= x_start && 0 < paintlen && - x_start + paintlen <= COLS); - mvwaddnstr(edit, yval, x_start, + assert(0 <= x_start && 0 < paintlen && + x_start + paintlen <= COLS); + mvwaddnstr(edit, yval, x_start, fileptr->data + start + x_start, paintlen); + } } else if (!searched_later_lines) { searched_later_lines = 1; /* There is no end on this line. But we haven't