From 484352241e7c1d4257161cb427943524f653966e Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 21 Oct 2004 16:51:45 +0000
Subject: [PATCH] in do_replace_loop(), check for more than one wrap at the
 right place

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2007 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 src/search.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/src/search.c b/src/search.c
index 70edcfd1..c24a0c23 100644
--- a/src/search.c
+++ b/src/search.c
@@ -728,24 +728,22 @@ ssize_t do_replace_loop(const char *needle, filestruct *real_current,
 #endif
 
 #ifndef NANO_SMALL
-	/* If we've found a match outside the marked text, skip over it
-	 * and search for another one. */
+	/* Keep track of how many times the search has wrapped.  If it's
+	 * wrapped more than once, it means that the only matches left
+	 * are those outside the marked text, so we're done. */
+	if (wrapped)
+	    wraps++;
+	if (wraps > 1)
+	    break;
+
+	/* Otherwise, if we've found a match outside the marked text,
+	 * skip over it and search for another one. */
 	if (old_mark_set) {
 	    if (current->lineno < top->lineno || current->lineno >
 		bot->lineno || (current == top && current_x < top_x) ||
 		(current == bot && (current_x > bot_x || current_x +
-		match_len > bot_x))) {
-		/* Keep track of how many times the search has wrapped.
-		 * If it's wrapped more than once, it means that the
-		 * only matches left are those outside the marked text,
-		 * so we're done. */
-		if (wrapped) {
-		    wraps++;
-		    if (wraps > 1)
-			break;
-		}
+		match_len > bot_x)))
 		continue;
-	    }
 	}
 #endif
 
-- 
GitLab