From c10c033083d88d7e50a2c183599329a724ffa57a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20M=C3=BCller?= <deso@posteo.net>
Date: Tue, 17 Dec 2024 08:02:44 -0800
Subject: [PATCH 2/3] Fix repeated-search direction

It is utterly confusing and counter to how many other programs behave
to make repeated searches in the command output stateful in such a way
that search direction depends on the direction of the initial search.
With this change we change the behavior of the search-again and
search-reverse commands to always search in upward or downward
direction, respectively. As a result, the search-reverse command is now
a misnomer, but that is acceptable for a one-off patch, and certainly
less invasive than a fully blown rename or the introduction of a new
command.
---
 window-copy.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/window-copy.c b/window-copy.c
index 25b3a7..8cf2d8 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -2518,10 +2518,7 @@ window_copy_cmd_search_again(struct window_copy_cmd_state *cs)
 	struct window_copy_mode_data	*data = wme->data;
 	u_int				 np = wme->prefix;
 
-	if (data->searchtype == WINDOW_COPY_SEARCHUP) {
-		for (; np != 0; np--)
-			window_copy_search_up(wme, data->searchregex);
-	} else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) {
+	if (data->searchtype != WINDOW_COPY_OFF) {
 		for (; np != 0; np--)
 			window_copy_search_down(wme, data->searchregex);
 	}
@@ -2535,10 +2532,7 @@ window_copy_cmd_search_reverse(struct window_copy_cmd_state *cs)
 	struct window_copy_mode_data	*data = wme->data;
 	u_int				 np = wme->prefix;
 
-	if (data->searchtype == WINDOW_COPY_SEARCHUP) {
-		for (; np != 0; np--)
-			window_copy_search_down(wme, data->searchregex);
-	} else if (data->searchtype == WINDOW_COPY_SEARCHDOWN) {
+	if (data->searchtype != WINDOW_COPY_OFF) {
 		for (; np != 0; np--)
 			window_copy_search_up(wme, data->searchregex);
 	}
-- 
2.55.0

