Skip to content

Commit

Permalink
Customized ctrl+c to behave as esc in autocomplete popup helix-editor…
Browse files Browse the repository at this point in the history
  • Loading branch information
rcastill committed Jul 1, 2022
1 parent 26501af commit cceaa20
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::compositor::{Component, Context, EventResult};
use crossterm::event::{Event, KeyCode, KeyEvent};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
use helix_view::editor::CompleteAction;
use tui::buffer::Buffer as Surface;

Expand Down Expand Up @@ -288,11 +288,15 @@ 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);
// https://github.com/helix-editor/helix/issues/822
// ctrl+c should also escape form insert mode
if let Event::Key(keyev) = event {
// I'm aware of ctrl!
// but that creates a view::KeyEvent we need crossterm
let ctrl_c = KeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL);
if keyev.code == KeyCode::Esc || keyev == ctrl_c {
return EventResult::Ignored(None);
}
}
self.popup.handle_event(event, cx)
}
Expand Down

0 comments on commit cceaa20

Please sign in to comment.