From c2fde58701d3d0a55ba15ba6004df7ca009175b9 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 25 Nov 2019 20:42:18 +0000 Subject: [PATCH 1/2] Do not clear search marks on cursor movement with vi(1) keys, from Eric Pruitt in GitHub issue 1985. --- window-copy.c | 139 +++++++++++++++++++++++++++----------------------- 1 file changed, 74 insertions(+), 65 deletions(-) diff --git a/window-copy.c b/window-copy.c index 01dc1f85..e3191983 100644 --- a/window-copy.c +++ b/window-copy.c @@ -1837,133 +1837,134 @@ static const struct { const char *command; int minargs; int maxargs; + int ismotion; enum window_copy_cmd_action (*f)(struct window_copy_cmd_state *); } window_copy_cmd_table[] = { - { "append-selection", 0, 0, + { "append-selection", 0, 0, 0, window_copy_cmd_append_selection }, - { "append-selection-and-cancel", 0, 0, + { "append-selection-and-cancel", 0, 0, 0, window_copy_cmd_append_selection_and_cancel }, - { "back-to-indentation", 0, 0, + { "back-to-indentation", 0, 0, 0, window_copy_cmd_back_to_indentation }, - { "begin-selection", 0, 0, + { "begin-selection", 0, 0, 0, window_copy_cmd_begin_selection }, - { "bottom-line", 0, 0, + { "bottom-line", 0, 0, 1, window_copy_cmd_bottom_line }, - { "cancel", 0, 0, + { "cancel", 0, 0, 0, window_copy_cmd_cancel }, - { "clear-selection", 0, 0, + { "clear-selection", 0, 0, 0, window_copy_cmd_clear_selection }, - { "copy-end-of-line", 0, 1, + { "copy-end-of-line", 0, 1, 0, window_copy_cmd_copy_end_of_line }, - { "copy-line", 0, 1, + { "copy-line", 0, 1, 0, window_copy_cmd_copy_line }, - { "copy-pipe-no-clear", 1, 2, + { "copy-pipe-no-clear", 1, 2, 0, window_copy_cmd_copy_pipe_no_clear }, - { "copy-pipe", 1, 2, + { "copy-pipe", 1, 2, 0, window_copy_cmd_copy_pipe }, - { "copy-pipe-and-cancel", 1, 2, + { "copy-pipe-and-cancel", 1, 2, 0, window_copy_cmd_copy_pipe_and_cancel }, - { "copy-selection-no-clear", 0, 1, + { "copy-selection-no-clear", 0, 1, 0, window_copy_cmd_copy_selection_no_clear }, - { "copy-selection", 0, 1, + { "copy-selection", 0, 1, 0, window_copy_cmd_copy_selection }, - { "copy-selection-and-cancel", 0, 1, + { "copy-selection-and-cancel", 0, 1, 0, window_copy_cmd_copy_selection_and_cancel }, - { "cursor-down", 0, 0, + { "cursor-down", 0, 0, 1, window_copy_cmd_cursor_down }, - { "cursor-down-and-cancel", 0, 0, + { "cursor-down-and-cancel", 0, 0, 0, window_copy_cmd_cursor_down_and_cancel }, - { "cursor-left", 0, 0, + { "cursor-left", 0, 0, 1, window_copy_cmd_cursor_left }, - { "cursor-right", 0, 0, + { "cursor-right", 0, 0, 1, window_copy_cmd_cursor_right }, - { "cursor-up", 0, 0, + { "cursor-up", 0, 0, 1, window_copy_cmd_cursor_up }, - { "end-of-line", 0, 0, + { "end-of-line", 0, 0, 1, window_copy_cmd_end_of_line }, - { "goto-line", 1, 1, + { "goto-line", 1, 1, 1, window_copy_cmd_goto_line }, - { "halfpage-down", 0, 0, + { "halfpage-down", 0, 0, 1, window_copy_cmd_halfpage_down }, - { "halfpage-down-and-cancel", 0, 0, + { "halfpage-down-and-cancel", 0, 0, 0, window_copy_cmd_halfpage_down_and_cancel }, - { "halfpage-up", 0, 0, + { "halfpage-up", 0, 0, 1, window_copy_cmd_halfpage_up }, - { "history-bottom", 0, 0, + { "history-bottom", 0, 0, 1, window_copy_cmd_history_bottom }, - { "history-top", 0, 0, + { "history-top", 0, 0, 1, window_copy_cmd_history_top }, - { "jump-again", 0, 0, + { "jump-again", 0, 0, 1, window_copy_cmd_jump_again }, - { "jump-backward", 1, 1, + { "jump-backward", 1, 1, 1, window_copy_cmd_jump_backward }, - { "jump-forward", 1, 1, + { "jump-forward", 1, 1, 1, window_copy_cmd_jump_forward }, - { "jump-reverse", 0, 0, + { "jump-reverse", 0, 0, 1, window_copy_cmd_jump_reverse }, - { "jump-to-backward", 1, 1, + { "jump-to-backward", 1, 1, 1, window_copy_cmd_jump_to_backward }, - { "jump-to-forward", 1, 1, + { "jump-to-forward", 1, 1, 1, window_copy_cmd_jump_to_forward }, - { "middle-line", 0, 0, + { "middle-line", 0, 0, 1, window_copy_cmd_middle_line }, - { "next-matching-bracket", 0, 0, + { "next-matching-bracket", 0, 0, 0, window_copy_cmd_next_matching_bracket }, - { "next-paragraph", 0, 0, + { "next-paragraph", 0, 0, 1, window_copy_cmd_next_paragraph }, - { "next-space", 0, 0, + { "next-space", 0, 0, 1, window_copy_cmd_next_space }, - { "next-space-end", 0, 0, + { "next-space-end", 0, 0, 1, window_copy_cmd_next_space_end }, - { "next-word", 0, 0, + { "next-word", 0, 0, 1, window_copy_cmd_next_word }, - { "next-word-end", 0, 0, + { "next-word-end", 0, 0, 1, window_copy_cmd_next_word_end }, - { "other-end", 0, 0, + { "other-end", 0, 0, 1, window_copy_cmd_other_end }, - { "page-down", 0, 0, + { "page-down", 0, 0, 1, window_copy_cmd_page_down }, - { "page-down-and-cancel", 0, 0, + { "page-down-and-cancel", 0, 0, 0, window_copy_cmd_page_down_and_cancel }, - { "page-up", 0, 0, + { "page-up", 0, 0, 1, window_copy_cmd_page_up }, - { "previous-matching-bracket", 0, 0, + { "previous-matching-bracket", 0, 0, 0, window_copy_cmd_previous_matching_bracket }, - { "previous-paragraph", 0, 0, + { "previous-paragraph", 0, 0, 1, window_copy_cmd_previous_paragraph }, - { "previous-space", 0, 0, + { "previous-space", 0, 0, 1, window_copy_cmd_previous_space }, - { "previous-word", 0, 0, + { "previous-word", 0, 0, 1, window_copy_cmd_previous_word }, - { "rectangle-toggle", 0, 0, + { "rectangle-toggle", 0, 0, 0, window_copy_cmd_rectangle_toggle }, - { "scroll-down", 0, 0, + { "scroll-down", 0, 0, 1, window_copy_cmd_scroll_down }, - { "scroll-down-and-cancel", 0, 0, + { "scroll-down-and-cancel", 0, 0, 0, window_copy_cmd_scroll_down_and_cancel }, - { "scroll-up", 0, 0, + { "scroll-up", 0, 0, 1, window_copy_cmd_scroll_up }, - { "search-again", 0, 0, + { "search-again", 0, 0, 0, window_copy_cmd_search_again }, - { "search-backward", 0, 1, + { "search-backward", 0, 1, 0, window_copy_cmd_search_backward }, - { "search-backward-incremental", 1, 1, + { "search-backward-incremental", 1, 1, 0, window_copy_cmd_search_backward_incremental }, - { "search-forward", 0, 1, + { "search-forward", 0, 1, 0, window_copy_cmd_search_forward }, - { "search-forward-incremental", 1, 1, + { "search-forward-incremental", 1, 1, 0, window_copy_cmd_search_forward_incremental }, - { "search-reverse", 0, 0, + { "search-reverse", 0, 0, 0, window_copy_cmd_search_reverse }, - { "select-line", 0, 0, + { "select-line", 0, 0, 0, window_copy_cmd_select_line }, - { "select-word", 0, 0, + { "select-word", 0, 0, 0, window_copy_cmd_select_word }, - { "start-of-line", 0, 0, + { "start-of-line", 0, 0, 1, window_copy_cmd_start_of_line }, - { "stop-selection", 0, 0, + { "stop-selection", 0, 0, 0, window_copy_cmd_stop_selection }, - { "top-line", 0, 0, + { "top-line", 0, 0, 1, 1, window_copy_cmd_top_line }, }; @@ -1977,6 +1978,7 @@ window_copy_command(struct window_mode_entry *wme, struct client *c, enum window_copy_cmd_action action; const char *command; u_int i; + int ismotion, keys; if (args->argc == 0) return; @@ -1999,16 +2001,23 @@ window_copy_command(struct window_mode_entry *wme, struct client *c, if (args->argc - 1 < window_copy_cmd_table[i].minargs || args->argc - 1 > window_copy_cmd_table[i].maxargs) break; + ismotion = window_copy_cmd_table[i].ismotion; action = window_copy_cmd_table[i].f (&cs); break; } } if (strncmp(command, "search-", 7) != 0 && data->searchmark != NULL) { - window_copy_clear_marks(wme); + keys = options_get_number(wme->wp->window->options, "mode-keys"); + if (keys != MODEKEY_VI || !ismotion) { + window_copy_clear_marks(wme); + data->searchx = data->searchy = -1; + } else if (data->searchthis != -1) { + data->searchthis = -1; + action = WINDOW_COPY_CMD_REDRAW; + } if (action == WINDOW_COPY_CMD_NOTHING) action = WINDOW_COPY_CMD_REDRAW; - data->searchx = data->searchy = -1; } wme->prefix = 1; From 87a11a921455538ba4594e0852439f84e7b84a4c Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 25 Nov 2019 20:43:32 +0000 Subject: [PATCH 2/2] Fix a warning in previous. --- window-copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window-copy.c b/window-copy.c index e3191983..8b03cfcf 100644 --- a/window-copy.c +++ b/window-copy.c @@ -1964,7 +1964,7 @@ static const struct { window_copy_cmd_start_of_line }, { "stop-selection", 0, 0, 0, window_copy_cmd_stop_selection }, - { "top-line", 0, 0, 1, 1, + { "top-line", 0, 0, 1, window_copy_cmd_top_line }, };