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:
Johannes Altmanninger
2022-01-30 19:19:43 +01:00
parent 6bdb99972d
commit 8b9f7dbf45
2 changed files with 15 additions and 0 deletions

View File

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

View 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