1
1

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.
Этот коммит содержится в:
Benno Schulenberg 2020-06-02 10:50:18 +02:00
родитель 881106c487
Коммит 569d00564b

Просмотреть файл

@ -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++;