on master help sign in
Use Popup::ignore_escape_key helper for completion (#6006)
d8526a7Michael Davis
helix-term/src/ui/completion.rs+4−13
@@ -9,11 +9,7 @@ use tui::{buffer::Buffer as Surface, text::Span};
9use std::borrow::Cow;
9use std::borrow::Cow;
10
10
11use helix_core::{Change, Transaction};
11use helix_core::{Change, Transaction};
12−use helix_view::{
13− graphics::Rect,
14− input::{KeyCode, KeyEvent},
15− Document, Editor,
12+use helix_view::{graphics::Rect, Document, Editor};
16−};
17
13
18use crate::commands;
14use crate::commands;
19use crate::ui::{menu, Markdown, Menu, Popup, PromptEvent};
15use crate::ui::{menu, Markdown, Menu, Popup, PromptEvent};
@@ -254,7 +250,9 @@ impl Completion {
254 }
250 }
255 };
251 };
256 });
252 });
257− let popup = Popup::new(Self::ID, menu).with_scrollbar(false);
253+ let popup = Popup::new(Self::ID, menu)
254+ .with_scrollbar(false)
255+ .ignore_escape_key(true);
258 let mut completion = Self {
256 let mut completion = Self {
259 popup,
257 popup,
260 start_offset,
258 start_offset,
@@ -378,13 +376,6 @@ impl Completion {
378
376
379impl Component for Completion {
377impl Component for Completion {
380 fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
378 fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
381− // let the Editor handle Esc instead
382− if let Event::Key(KeyEvent {
383− code: KeyCode::Esc, ..
384− }) = event
385− {
386− return EventResult::Ignored(None);
387− }
388 self.popup.handle_event(event, cx)
379 self.popup.handle_event(event, cx)
389 }
380 }
390
381