From 6c0ae7477e4836525fce6adb9cd6877277a0f72f Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sat, 25 May 2019 08:31:36 +0200 Subject: [PATCH] reader: Only abort history search on cancel Otherwise we'd undo the history search when you press e.g. execute, which means you'd execute the search term. Only `cancel` should walk it back, like it previously did hardcoded to escape. Fixes #5891. --- src/reader.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index 4d663b5ac..66e889400 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -3267,11 +3267,12 @@ maybe_t reader_data_t::readline(int nchars_or_0) { handle_readline_command(readline_cmd, rls); if (command_ends_history_search(readline_cmd)) { - if (history_search.active()) { + // "cancel" means to abort the whole thing, other ending commands mean to finish the search. + if (history_search.active() && readline_cmd == rl::cancel) { history_search.go_to_end(); update_command_line_from_history_search(); - history_search.reset(); } + history_search.reset(); } rls.last_cmd = readline_cmd;