Fix regression of C-e always accepting autosuggestion

This commit is contained in:
Johannes Altmanninger 2024-02-17 01:27:43 +01:00
parent 8c91d1421a
commit b687ef036b
2 changed files with 28 additions and 14 deletions

View file

@ -2043,12 +2043,16 @@ impl ReaderData {
self.update_buff_pos(elt, Some(position - 1)); self.update_buff_pos(elt, Some(position - 1));
} }
} }
rl::EndOfLine => loop { rl::EndOfLine => {
let (_elt, el) = self.active_edit_line();
if el.position() == el.len() {
self.accept_autosuggestion(true, false, MoveWordStyle::Punctuation);
} else {
loop {
let position = { let position = {
let (_elt, el) = self.active_edit_line(); let (_elt, el) = self.active_edit_line();
let position = el.position(); let position = el.position();
if position == el.len() { if position == el.len() {
self.accept_autosuggestion(true, false, MoveWordStyle::Punctuation);
break; break;
} }
if el.text().char_at(position) == '\n' { if el.text().char_at(position) == '\n' {
@ -2057,7 +2061,9 @@ impl ReaderData {
position position
}; };
self.update_buff_pos(self.active_edit_line_tag(), Some(position + 1)); self.update_buff_pos(self.active_edit_line_tag(), Some(position + 1));
}, }
}
}
rl::BeginningOfBuffer => { rl::BeginningOfBuffer => {
self.update_buff_pos(EditableLineTag::Commandline, Some(0)); self.update_buff_pos(EditableLineTag::Commandline, Some(0));
} }

View file

@ -94,3 +94,11 @@ isolated-tmux send-keys C-s
tmux-sleep tmux-sleep
isolated-tmux capture-pane -p isolated-tmux capture-pane -p
# CHECK: prompt 7> echo suggest this # CHECK: prompt 7> echo suggest this
isolated-tmux send-keys C-u
isolated-tmux send-keys 'echo sugg' C-a
tmux-sleep
isolated-tmux send-keys C-e M-f Space nothing
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 7> echo suggest nothing