Fix Escape in pager not removing the inserted completion if search field was used

command_line_has_transient_edit tracks the actual command line, not the
pager search field. We accidentally reset it after modifying the search field
which causes unexpected behavior - the commandline added by the completion
pager remains even after I press Escape.
This commit is contained in:
Johannes Altmanninger 2022-07-26 09:23:44 +02:00
parent 3d8f643a5e
commit fe2f6f0c63
2 changed files with 13 additions and 2 deletions

View File

@ -1578,7 +1578,6 @@ void reader_data_t::delete_char(bool backward) {
void reader_data_t::insert_string(editable_line_t *el, const wcstring &str) {
if (str.empty()) return;
command_line_has_transient_edit = false;
if (!history_search.active() && want_to_coalesce_insertion_of(*el, str)) {
el->insert_coalesce(str);
assert(el->undo_history.may_coalesce);
@ -1587,7 +1586,10 @@ void reader_data_t::insert_string(editable_line_t *el, const wcstring &str) {
el->undo_history.may_coalesce = el->undo_history.try_coalesce || (str.size() == 1);
}
if (el == &command_line) suppress_autosuggestion = false;
if (el == &command_line) {
command_line_has_transient_edit = false;
suppress_autosuggestion = false;
}
// The pager needs to be refiltered.
if (el == &this->pager.search_field_line) {
command_line_changed(el);

View File

@ -39,3 +39,12 @@ isolated-tmux capture-pane -p | sed -n '1p;$p'
# CHECK: prompt 3> begin
# Also ensure that the pager is actually fully disclosed.
# CHECK: rows 1 to {{\d+}} of {{\d+}}
# Canceling the pager removes the inserted completion, no mater what happens in the search field.
# The common prefix remains because it is inserted before the pager is shown.
isolated-tmux send-keys C-c
tmux-sleep
isolated-tmux send-keys C-l foo2 Space BTab b BSpace b Escape
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 3> foo2 aa