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.
This commit is contained in:
Johannes Altmanninger 2020-03-14 20:35:24 +01:00
parent 8b961a0ca8
commit 971c2eb668

View file

@ -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;
}