Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Popup::ignore_escape_key helper for completion #6006

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ use tui::{buffer::Buffer as Surface, text::Span};
use std::borrow::Cow;

use helix_core::{Change, Transaction};
use helix_view::{
graphics::Rect,
input::{KeyCode, KeyEvent},
Document, Editor,
};
use helix_view::{graphics::Rect, Document, Editor};

use crate::commands;
use crate::ui::{menu, Markdown, Menu, Popup, PromptEvent};
Expand Down Expand Up @@ -254,7 +250,9 @@ impl Completion {
}
};
});
let popup = Popup::new(Self::ID, menu).with_scrollbar(false);
let popup = Popup::new(Self::ID, menu)
.with_scrollbar(false)
.ignore_escape_key(true);
let mut completion = Self {
popup,
start_offset,
Expand Down Expand Up @@ -378,13 +376,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