diff --git a/src/color.c b/src/color.c index ec6458d8f1f7cb072e6ab8539c7e2dc1d35efc3c..2227fc5c363472994a67136dca496d22e1d91d57 100644 --- a/src/color.c +++ b/src/color.c @@ -292,7 +292,7 @@ void color_update(void) /* Determine whether the matches of multiline regexes are still the same, * and if not, schedule a screen refresh, so things will be repainted. */ -void reset_multis(filestruct *fileptr, bool force) +void check_the_multis(filestruct *line) { const colortype *ink; int nobegin = 0, noend = 0; @@ -307,27 +307,25 @@ void reset_multis(filestruct *fileptr, bool force) if (ink->end == NULL) continue; - alloc_multidata_if_needed(fileptr); + alloc_multidata_if_needed(line); - if (force == FALSE) { /* Check whether the multidata still matches the current situation. */ - nobegin = regexec(ink->start, fileptr->data, 1, &startmatch, 0); - noend = regexec(ink->end, fileptr->data, 1, &endmatch, 0); - if (fileptr->multidata[ink->id] == CNONE || - fileptr->multidata[ink->id] == CWHOLELINE) { + nobegin = regexec(ink->start, line->data, 1, &startmatch, 0); + noend = regexec(ink->end, line->data, 1, &endmatch, 0); + if (line->multidata[ink->id] == CNONE || + line->multidata[ink->id] == CWHOLELINE) { if (nobegin && noend) continue; - } else if (fileptr->multidata[ink->id] == CSTARTENDHERE) { + } else if (line->multidata[ink->id] == CSTARTENDHERE) { if (!nobegin && !noend && startmatch.rm_so < endmatch.rm_so) continue; - } else if (fileptr->multidata[ink->id] == CBEGINBEFORE) { + } else if (line->multidata[ink->id] == CBEGINBEFORE) { if (nobegin && !noend) continue; - } else if (fileptr->multidata[ink->id] == CENDAFTER) { + } else if (line->multidata[ink->id] == CENDAFTER) { if (!nobegin && noend) continue; } - } refresh_needed = TRUE; return; diff --git a/src/cut.c b/src/cut.c index 871ebab3d9a588035100b69094915b588be80a4a..a64f2bd1504266f71d34d0cd197d44ccee4a72d7 100644 --- a/src/cut.c +++ b/src/cut.c @@ -194,7 +194,7 @@ void do_cut_text(bool copy_text, bool cut_till_eof) refresh_needed = TRUE; #ifndef DISABLE_COLOR - reset_multis(openfile->current, FALSE); + check_the_multis(openfile->current); #endif #ifdef DEBUG @@ -291,7 +291,7 @@ void do_uncut_text(void) refresh_needed = TRUE; #ifndef DISABLE_COLOR - reset_multis(openfile->current, FALSE); + check_the_multis(openfile->current); #endif #ifdef DEBUG diff --git a/src/nano.c b/src/nano.c index 9285c98fe6795144012c642de6a64467eaccd9cf..855b977333e5cc4cdbebd46662df03c5369656a1 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1690,7 +1690,7 @@ int do_input(bool allow_funcs) #endif #ifndef DISABLE_COLOR if (f && !f->viewok) - reset_multis(openfile->current, FALSE); + check_the_multis(openfile->current); #endif if (!refresh_needed && (s->scfunc == do_delete || s->scfunc == do_backspace)) update_line(openfile->current, openfile->current_x); @@ -1891,7 +1891,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) openfile->placewewant = xplustabs(); #ifndef DISABLE_COLOR - reset_multis(openfile->current, FALSE); + check_the_multis(openfile->current); #endif if (!refresh_needed) diff --git a/src/proto.h b/src/proto.h index 3945f07302ee0fa68148ad774dae3b9ed3d3ac00..3642ae31fcdc3b54ae94b4561210fa189679c043 100644 --- a/src/proto.h +++ b/src/proto.h @@ -266,7 +266,7 @@ bool is_valid_mbstring(const char *s); void set_colorpairs(void); void color_init(void); void color_update(void); -void reset_multis(filestruct *fileptr, bool force); +void check_the_multis(filestruct *line); void alloc_multidata_if_needed(filestruct *fileptr); void precalc_multicolorinfo(void); #endif diff --git a/src/search.c b/src/search.c index 5a69c33408d253d42a397dd185b5a30cc256a6e6..a8840822d09788fc39245d7a748aba419e03e7bc 100644 --- a/src/search.c +++ b/src/search.c @@ -719,13 +719,6 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only, free(openfile->current->data); openfile->current->data = copy; -#ifndef DISABLE_COLOR - /* Reset the precalculated multiline-regex hints only when - * the first replacement has been made. */ - if (numreplaced == 0) - reset_multis(openfile->current, TRUE); -#endif - if (!replaceall) { #ifndef DISABLE_COLOR /* When doing syntax coloring, the replacement might require @@ -745,6 +738,10 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only, if (numreplaced == -1) not_found_msg(needle); +#ifndef DISABLE_COLOR + else if (numreplaced > 0) + refresh_needed = TRUE; +#endif #ifndef NANO_TINY if (mark_was_set)