replacing: detect when the whole region has already been covered

Even when a match falls within the marked region, this does not mean
that it is a true match when already the whole file has been searched,
because then this is the second time we find this match.

This fixes https://savannah.gnu.org/bugs/?50158.
master
Benno Schulenberg 2017-01-26 21:25:15 +01:00
parent 94e563232e
commit 437cb410e9
1 changed files with 1 additions and 1 deletions

View File

@ -623,7 +623,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
if (old_mark_set) {
/* When we've found an occurrence outside of the marked region,
* stop the fanfare. */
if (openfile->current->lineno > bot->lineno ||
if (came_full_circle || openfile->current->lineno > bot->lineno ||
openfile->current->lineno < top->lineno ||
(openfile->current == bot && openfile->current_x + match_len > bot_x) ||
(openfile->current == top && openfile->current_x < top_x))