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.
This commit is contained in:
Fabian Homborg 2019-05-25 08:31:36 +02:00
parent a5a5ccb73d
commit 6c0ae7477e

View file

@ -3267,11 +3267,12 @@ maybe_t<wcstring> reader_data_t::readline(int nchars_or_0) {
handle_readline_command(readline_cmd, rls); handle_readline_command(readline_cmd, rls);
if (command_ends_history_search(readline_cmd)) { 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(); history_search.go_to_end();
update_command_line_from_history_search(); update_command_line_from_history_search();
history_search.reset();
} }
history_search.reset();
} }
rls.last_cmd = readline_cmd; rls.last_cmd = readline_cmd;