search: suppress the occurrence at the cursor only when replacing

When we're just searching, we do want to report the occurrence at
the cursor (after coming full circle) as a match, so that we can
mention that this is the only occurrence.  When replacing, we do
not want to replace this match twice.

This fixes https://savannah.gnu.org/bugs/?52888.
master
Benno Schulenberg 2018-01-14 22:17:47 +01:00
parent 6a4d88cb4c
commit 00c1105c1b
1 changed files with 2 additions and 1 deletions

View File

@ -328,7 +328,8 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
enable_waiting();
/* Ensure that the found occurrence is not beyond the starting x. */
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && found_x >= begin_x) ||
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && (found_x > begin_x ||
(modus == REPLACING && found_x == begin_x))) ||
(ISSET(BACKWARDS_SEARCH) && found_x < begin_x)))
return 0;