Commit transient edit when closing pager

When selecting items in the pager, only the latest of those items is kept
in the edit history, as so-called transient edit.  Each new transient edit
evicts any old transient edit (via undo).

If the pager is closed by a command that performs another transient edit
(like history-token-search-backward) we thus inadvertently undo (= remove)
the token inserted by the pager.  Fix this by closing a transient edit
session when closing the pager.  Token search will start its own session.

Fixes #9160
This commit is contained in:
Johannes Altmanninger 2022-08-31 07:33:46 +02:00
parent a6ff72bd64
commit 3b30d92b62
2 changed files with 7 additions and 0 deletions

View File

@ -2045,6 +2045,7 @@ void reader_data_t::accept_autosuggestion(bool full, bool single, move_word_styl
void reader_data_t::clear_pager() {
pager.clear();
history_pager_active = false;
command_line_has_transient_edit = false;
}
void reader_data_t::select_completion_in_direction(selection_motion_t dir,

View File

@ -68,3 +68,9 @@ isolated-tmux capture-pane -p | head -1
# The second one is the autosuggestion. Maybe we should turn them off for this test.
# TODO there should be a prefix ("prompt 4> foo4") but we fail to draw that in this case.
# CHECK: {{.*}} b-short-arg a-long-arg{{.*}}
# Check that completion pager followed by token search search inserts two separate tokens.
isolated-tmux send-keys C-u echo Space old-arg Enter C-l foo2 Space Tab Tab M-.
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 5> foo2 aabc old-arg