diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-08-14 10:02:25 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-08-14 10:02:25 +0000 |
commit | 20f59010148842de1d6ac1d380f884c3ea195839 (patch) | |
tree | 908412df9f4de1d9efb568192fb2d1baa77bcb47 /usr.bin/tmux/window-copy.c | |
parent | b3deb12555fbc5a580f3b8209cceb928de0dd2b0 (diff) |
Default to previous search string for search-forward and
search-backward, from Leah Neukirchen.
Diffstat (limited to 'usr.bin/tmux/window-copy.c')
-rw-r--r-- | usr.bin/tmux/window-copy.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index f713ef27471..f8e13010136 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.232 2019/08/14 09:59:43 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.233 2019/08/14 10:02:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1635,12 +1635,17 @@ window_copy_cmd_search_backward(struct window_copy_cmd_state *cs) struct window_mode_entry *wme = cs->wme; struct window_copy_mode_data *data = wme->data; u_int np = wme->prefix; - const char *argument = cs->args->argv[1]; + const char *argument; - if (*argument != '\0') { + if (cs->args->argc == 2) { + argument = cs->args->argv[1]; + if (*argument != '\0') { + free(data->searchstr); + data->searchstr = xstrdup(argument); + } + } + if (data->searchstr != NULL) { data->searchtype = WINDOW_COPY_SEARCHUP; - free(data->searchstr); - data->searchstr = xstrdup(argument); for (; np != 0; np--) window_copy_search_up(wme); } @@ -1653,12 +1658,17 @@ window_copy_cmd_search_forward(struct window_copy_cmd_state *cs) struct window_mode_entry *wme = cs->wme; struct window_copy_mode_data *data = wme->data; u_int np = wme->prefix; - const char *argument = cs->args->argv[1]; + const char *argument; - if (*argument != '\0') { + if (cs->args->argc == 2) { + argument = cs->args->argv[1]; + if (*argument != '\0') { + free(data->searchstr); + data->searchstr = xstrdup(argument); + } + } + if (data->searchstr != NULL) { data->searchtype = WINDOW_COPY_SEARCHDOWN; - free(data->searchstr); - data->searchstr = xstrdup(argument); for (; np != 0; np--) window_copy_search_down(wme); } @@ -1872,11 +1882,11 @@ static const struct { window_copy_cmd_scroll_up }, { "search-again", 0, 0, window_copy_cmd_search_again }, - { "search-backward", 1, 1, + { "search-backward", 0, 1, window_copy_cmd_search_backward }, { "search-backward-incremental", 1, 1, window_copy_cmd_search_backward_incremental }, - { "search-forward", 1, 1, + { "search-forward", 0, 1, window_copy_cmd_search_forward }, { "search-forward-incremental", 1, 1, window_copy_cmd_search_forward_incremental }, |