Skip to content

Commit

Permalink
Restore document state on completion cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
andreytkachenko committed Apr 13, 2022
1 parent 764adbd commit 9f0e78b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 1 addition & 7 deletions helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl Completion {

match event {
PromptEvent::Abort => {
doc.restore(view.id);
editor.last_completion = None;
}
PromptEvent::Update => {
Expand Down Expand Up @@ -282,13 +283,6 @@ impl Completion {

impl Component for Completion {
fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
// let the Editor handle Esc instead
if let Event::Key(KeyEvent {
code: KeyCode::Esc, ..
}) = event
{
return EventResult::Ignored(None);
}
self.popup.handle_event(event, cx)
}

Expand Down
5 changes: 4 additions & 1 deletion helix-term/src/ui/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ impl<T: Component> Component for Popup<T> {

match key.into() {
// esc or ctrl-c aborts the completion and closes the menu
key!(Esc) | ctrl!('c') => EventResult::Consumed(Some(close_fn)),
key!(Esc) | ctrl!('c') => {
let _ = self.contents.handle_event(event, cx);
EventResult::Consumed(Some(close_fn))
}
ctrl!('d') => {
self.scroll(self.size.1 as usize / 2, true);
EventResult::Consumed(None)
Expand Down

0 comments on commit 9f0e78b

Please sign in to comment.