mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 14:01:20 -03:00
Commit transient edit when history search ends
A history search ends when you move the cursor, but the commandline inserted by history search is still marked as transient. This means that the next history search will clear the transient commandline. This means we are dropping an undo point, for example: echo 11 echo 1 echo autosuggestion echo^P # commandline is "echo 1" ^A # stop history search ^P # commandline is "echo 11" ^Z # Bug: commandline goes back to "echo", but it should be "echo 1" In the worst case, we are switching from line-search to token-search (see the attached test case). Clearing the transient edit means the line is gone and only the token is left on the command line.
This commit is contained in:
@@ -4094,6 +4094,7 @@ maybe_t<wcstring> reader_data_t::readline(int nchars_or_0) {
|
||||
clear_transient_edit();
|
||||
}
|
||||
history_search.reset();
|
||||
command_line_has_transient_edit = false;
|
||||
}
|
||||
|
||||
rls.last_cmd = readline_cmd;
|
||||
|
||||
14
tests/checks/tmux-history-search.fish
Normal file
14
tests/checks/tmux-history-search.fish
Normal file
@@ -0,0 +1,14 @@
|
||||
#RUN: %fish %s
|
||||
#REQUIRES: command -v tmux
|
||||
|
||||
isolated-tmux-start
|
||||
|
||||
isolated-tmux send-keys 'true needle' Enter
|
||||
# CHECK: prompt 0> true needle
|
||||
tmux-sleep
|
||||
isolated-tmux send-keys 'true hay ee hay' Enter
|
||||
# CHECK: prompt 1> true hay ee hay
|
||||
isolated-tmux send-keys C-p C-a M-f M-f M-f M-.
|
||||
# CHECK: prompt 2> true hay needle hay
|
||||
tmux-sleep
|
||||
isolated-tmux capture-pane -p
|
||||
Reference in New Issue
Block a user