Restore document state on completion cancel (#2096)

This commit is contained in:
Andrey Tkachenko 2022-04-20 05:42:33 +04:00 committed by GitHub
parent cc68fa857d
commit 3a7bf1c40c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -135,6 +135,7 @@ impl Completion {
match event {
PromptEvent::Abort => {
doc.restore(view.id);
editor.last_completion = None;
}
PromptEvent::Update => {

View file

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