mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 11:22:52 +08:00
Copy history pager search field to command line on Enter if no match
Closes #9934
(cherry picked from commit b7f7dcf788
)
This commit is contained in:
parent
64bff1a51c
commit
211a3ceee1
|
@ -4389,6 +4389,13 @@ bool reader_data_t::handle_execute(readline_loop_state_t &rls) {
|
|||
// using a backslash, insert a newline.
|
||||
// If the user hits return while navigating the pager, it only clears the pager.
|
||||
if (is_navigating_pager_contents()) {
|
||||
if (this->history_pager_active &&
|
||||
this->pager.selected_completion_index() == PAGER_SELECTION_NONE) {
|
||||
command_line.push_edit(
|
||||
edit_t{0, command_line.size(), this->pager.search_field_line.text()},
|
||||
/* allow_coalesce */ false);
|
||||
command_line.set_position(this->pager.search_field_line.position());
|
||||
}
|
||||
clear_pager();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,3 +27,10 @@ isolated-tmux send-keys C-z _
|
|||
tmux-sleep
|
||||
isolated-tmux capture-pane -p | grep 'prompt 2'
|
||||
# CHECK: prompt 2> _
|
||||
|
||||
# When history pager fails to find a result, copy the search field to the command line.
|
||||
isolated-tmux send-keys C-e C-u C-r "echo no such command in history"
|
||||
tmux-sleep
|
||||
isolated-tmux send-keys Enter
|
||||
# CHECK: prompt 2> echo no such command in history
|
||||
isolated-tmux capture-pane -p | grep 'prompt 2'
|
||||
|
|
Loading…
Reference in New Issue
Block a user