Remove catch all keymap and KeyPressed action

This commit is contained in:
Kay Simmons 2023-02-10 16:09:15 -08:00
parent 459060764a
commit 327932ba3b
4 changed files with 14 additions and 45 deletions

View file

@ -6,24 +6,15 @@ mod keystroke;
use std::{any::TypeId, fmt::Debug};
use collections::HashMap;
use serde::Deserialize;
use smallvec::SmallVec;
use crate::{impl_actions, Action};
use crate::Action;
pub use binding::{Binding, BindingMatchResult};
pub use keymap::Keymap;
pub use keymap_context::{KeymapContext, KeymapContextPredicate};
pub use keystroke::Keystroke;
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize)]
pub struct KeyPressed {
#[serde(default)]
pub keystroke: Keystroke,
}
impl_actions!(gpui, [KeyPressed]);
pub struct KeymapMatcher {
pub contexts: Vec<KeymapContext>,
pending_views: HashMap<usize, KeymapContext>,
@ -102,13 +93,7 @@ impl KeymapMatcher {
for binding in self.keymap.bindings().iter().rev() {
match binding.match_keys_and_context(&self.pending_keystrokes, &self.contexts[i..])
{
BindingMatchResult::Complete(mut action) => {
// Swap in keystroke for special KeyPressed action
if action.name() == "KeyPressed" && action.namespace() == "gpui" {
action = Box::new(KeyPressed {
keystroke: keystroke.clone(),
});
}
BindingMatchResult::Complete(action) => {
matched_bindings.push((view_id, action))
}
BindingMatchResult::Partial => {