nano

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

commit 00c1105c1b7bc6572d24f2943315fe4be94211ba
parent 6a4d88cb4c3fd6b5e3bcfecf502eba8f9245ac04
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 14 Jan 2018 22:17:47 +0100

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.

Diffstat:
Msrc/search.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/search.c b/src/search.c @@ -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;