From a7ee9f74f771a486f99dca9e7a6084f74f19eb46 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Sun, 20 Mar 2022 15:55:11 +0900 Subject: No need for KeymapResult anymore since we can query .sticky() --- helix-term/src/ui/editor.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'helix-term/src/ui/editor.rs') diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index a0c0e773..611d65fb 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -2,7 +2,7 @@ use crate::{ commands, compositor::{Component, Context, EventResult}, key, - keymap::{KeymapResult, KeymapResultKind, Keymaps}, + keymap::{KeymapResult, Keymaps}, ui::{Completion, ProgressSpinners}, }; @@ -694,7 +694,7 @@ impl EditorView { /// Handle events by looking them up in `self.keymaps`. Returns None /// if event was handled (a command was executed or a subkeymap was - /// activated). Only KeymapResultKind::{NotFound, Cancelled} is returned + /// activated). Only KeymapResult::{NotFound, Cancelled} is returned /// otherwise. fn handle_keymap_event( &mut self, @@ -704,36 +704,36 @@ impl EditorView { ) -> Option { cxt.editor.autoinfo = None; let key_result = self.keymaps.get(mode, event); - cxt.editor.autoinfo = key_result.sticky.map(|node| node.infobox()); + cxt.editor.autoinfo = self.keymaps.sticky().map(|node| node.infobox()); - match &key_result.kind { - KeymapResultKind::Matched(command) => command.execute(cxt), - KeymapResultKind::Pending(node) => cxt.editor.autoinfo = Some(node.infobox()), - KeymapResultKind::MatchedSequence(commands) => { + match &key_result { + KeymapResult::Matched(command) => command.execute(cxt), + KeymapResult::Pending(node) => cxt.editor.autoinfo = Some(node.infobox()), + KeymapResult::MatchedSequence(commands) => { for command in commands { command.execute(cxt); } } - KeymapResultKind::NotFound | KeymapResultKind::Cancelled(_) => return Some(key_result), + KeymapResult::NotFound | KeymapResult::Cancelled(_) => return Some(key_result), } None } fn insert_mode(&mut self, cx: &mut commands::Context, event: KeyEvent) { if let Some(keyresult) = self.handle_keymap_event(Mode::Insert, cx, event) { - match keyresult.kind { - KeymapResultKind::NotFound => { + match keyresult { + KeymapResult::NotFound => { if let Some(ch) = event.char() { commands::insert::insert_char(cx, ch) } } - KeymapResultKind::Cancelled(pending) => { + KeymapResult::Cancelled(pending) => { for ev in pending { match ev.char() { Some(ch) => commands::insert::insert_char(cx, ch), None => { - if let KeymapResultKind::Matched(command) = - self.keymaps.get(Mode::Insert, ev).kind + if let KeymapResult::Matched(command) = + self.keymaps.get(Mode::Insert, ev) { command.execute(cx); } @@ -1182,8 +1182,8 @@ impl Component for EditorView { // how we entered insert mode is important, and we should track that so // we can repeat the side effect. - self.last_insert.0 = match self.keymaps.get(mode, key).kind { - KeymapResultKind::Matched(command) => command, + self.last_insert.0 = match self.keymaps.get(mode, key) { + KeymapResult::Matched(command) => command, // FIXME: insert mode can only be entered through single KeyCodes _ => unimplemented!(), }; -- cgit v1.2.3-70-g09d2