nano

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

commit 569d00564b7751d1910b1fd727eb401e1d7f9544
parent 881106c4879a403e37c3361a231cfa24f8184e7c
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue,  2 Jun 2020 10:50:18 +0200

replacing: recalculate the multiline coloring info when needed

If a replacement changed the matching of a multiline coloring regex,
then wipe the existing multiline data and recalculate it for the whole
buffer.

There is no need to redraw the current line (let alone the whole window)
directly after a replacement, because if there is a next occurrence, the
edit window will be redrawn then in order to spotlight that occurrence;
and if there is no other occurrence, the edit window will be redrawn in
the main loop because there has been at least one replacement.

This fixes https://savannah.gnu.org/bugs/?58481.

Bug existed (in this form) since version 2.7.5.  Before that,
the miscoloring could happen even without scrolling.

Diffstat:
Msrc/search.c | 20+++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/search.c b/src/search.c @@ -642,17 +642,19 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only, free(openfile->current->data); openfile->current->data = copy; - if (!replaceall) { #ifdef ENABLE_COLOR - /* When doing syntax coloring, the replacement might require - * a change of colors, so refresh the whole edit window. */ - if (openfile->syntax && !ISSET(NO_SYNTAX)) - edit_refresh(); - else -#endif - update_line(openfile->current, openfile->current_x); - } + check_the_multis(openfile->current); + + /* If the replacement requires a change in the coloring, + * reset all the multiline data and recalculate it. */ + if (refresh_needed) { + for (linestruct *line = openfile->filetop; line != NULL; line = line->next) + for (short index = 0; index < openfile->syntax->nmultis; index++) + line->multidata[index] = -1; + precalc_multicolorinfo(); + } +#endif set_modified(); as_an_at = TRUE; numreplaced++;