This behaves similarily to POSIX vi and gives a nice way to reverse
search direction for search-again.

Signed-off-by: Leah Neukirchen <[email protected]>
---
 window-copy.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/window-copy.c b/window-copy.c
index 5b197e65..99bb5be6 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1638,9 +1638,11 @@ window_copy_cmd_search_backward(struct 
window_copy_cmd_state *cs)
        const char                      *argument = cs->args->argv[1];
 
        if (*argument != '\0') {
-               data->searchtype = WINDOW_COPY_SEARCHUP;
                free(data->searchstr);
                data->searchstr = xstrdup(argument);
+       }
+       if (data->searchstr) {
+               data->searchtype = WINDOW_COPY_SEARCHUP;
                for (; np != 0; np--)
                        window_copy_search_up(wme);
        }
@@ -1656,9 +1658,11 @@ window_copy_cmd_search_forward(struct 
window_copy_cmd_state *cs)
        const char                      *argument = cs->args->argv[1];
 
        if (*argument != '\0') {
-               data->searchtype = WINDOW_COPY_SEARCHDOWN;
                free(data->searchstr);
                data->searchstr = xstrdup(argument);
+       }
+       if (data->searchstr) {
+               data->searchtype = WINDOW_COPY_SEARCHDOWN;
                for (; np != 0; np--)
                        window_copy_search_down(wme);
        }
-- 
2.22.0

-- 
You received this message because you are subscribed to the Google Groups 
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/tmux-users/20190808114507.14835-1-leah%40vuxu.org.

Reply via email to