mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Copy history pager search field to command line on Enter if no match
Closes #9934
This commit is contained in:
parent
3a484480bf
commit
b7f7dcf788
@ -4404,6 +4404,13 @@ bool reader_data_t::handle_execute(readline_loop_state_t &rls) {
|
|||||||
// using a backslash, insert a newline.
|
// using a backslash, insert a newline.
|
||||||
// If the user hits return while navigating the pager, it only clears the pager.
|
// If the user hits return while navigating the pager, it only clears the pager.
|
||||||
if (is_navigating_pager_contents()) {
|
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();
|
clear_pager();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -27,3 +27,10 @@ isolated-tmux send-keys C-z _
|
|||||||
tmux-sleep
|
tmux-sleep
|
||||||
isolated-tmux capture-pane -p | grep 'prompt 2'
|
isolated-tmux capture-pane -p | grep 'prompt 2'
|
||||||
# CHECK: 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…
x
Reference in New Issue
Block a user