on master help sign in
Use Popup::ignore_escape_key helper for completion (#6006)

The completion component has a separate branch for handling the Escape key but it can use the `ignore_escape_key` helper added for signature-help instead. This should not cause a behavior change - it's just cleaning up the completion component.

commitd8526a752c52e73f041f76869c0e040959632927 authorMichael Davis <mcarsondavis@gmail.com> dateWed 15 Feb 2023, 19:15 (4 years ago) parent4c85f4d
1 file changed+4−13
helix-term/src/ui/completion.rs+4−13
helix-term/src/ui/completion.rs+4−13
@@ -9,11 +9,7 @@ use tui::{buffer::Buffer as Surface, text::Span};
99use std::borrow::Cow;
1010
1111use helix_core::{Change, Transaction};
12−use helix_view::{
13− graphics::Rect,
14− input::{KeyCode, KeyEvent},
15− Document, Editor,
16−};
12+use helix_view::{graphics::Rect, Document, Editor};
1713
1814use crate::commands;
1915use crate::ui::{menu, Markdown, Menu, Popup, PromptEvent};
@@ -254,7 +250,9 @@ impl Completion {
254250 }
255251 };
256252 });
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);
258256 let mut completion = Self {
259257 popup,
260258 start_offset,
@@ -378,13 +376,6 @@ impl Completion {
378376
379377impl Component for Completion {
380378 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− }
388379 self.popup.handle_event(event, cx)
389380 }
390381