From 971c2eb668bb3d58facb42c8f556858ac92b25c0 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 14 Mar 2020 20:35:24 +0100 Subject: [PATCH] history search: do not move the cursor after failing backward search When editing a multiline command line and pressing "up" with the cursor at the first line, fish attempts a hsitory search. If the search fails, don't move the cursor to the end of the multiline command because this can be annoying when the user does not actually want to perform a history search. --- src/reader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index 9d10e88f6..ee3110ec1 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -3039,8 +3039,10 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat c == rl::history_prefix_search_backward) ? history_search_direction_t::backward : history_search_direction_t::forward; - history_search.move_in_direction(dir); - update_command_line_from_history_search(); + if (history_search.move_in_direction(dir) || + (dir == history_search_direction_t::forward && history_search.is_at_end())) { + update_command_line_from_history_search(); + } } break; }