Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/keymap.rs')
| -rw-r--r-- | helix-term/src/keymap.rs | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index d8227b50..598be55b 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -106,7 +106,7 @@ impl KeyTrieNode { (events.join(", "), desc) }) .collect(); - Info::new(self.name.clone(), &body) + Info::new(&self.name, &body) } } @@ -177,19 +177,6 @@ impl<'de> serde::de::Visitor<'de> for KeyTrieVisitor { .map_err(serde::de::Error::custom)?, ) } - - // Prevent macro keybindings from being used in command sequences. - // This is meant to be a temporary restriction pending a larger - // refactor of how command sequences are executed. - if commands - .iter() - .any(|cmd| matches!(cmd, MappableCommand::Macro { .. })) - { - return Err(serde::de::Error::custom( - "macro keybindings may not be used in command sequences", - )); - } - Ok(KeyTrie::Sequence(commands)) } @@ -212,7 +199,6 @@ impl KeyTrie { // recursively visit all nodes in keymap fn map_node(cmd_map: &mut ReverseKeymap, node: &KeyTrie, keys: &mut Vec<KeyEvent>) { match node { - KeyTrie::MappableCommand(MappableCommand::Macro { .. }) => {} KeyTrie::MappableCommand(cmd) => { let name = cmd.name(); if name != "no_op" { @@ -317,15 +303,6 @@ impl Keymaps { self.sticky.as_ref() } - pub fn contains_key(&self, mode: Mode, key: KeyEvent) -> bool { - let keymaps = &*self.map(); - let keymap = &keymaps[&mode]; - keymap - .search(self.pending()) - .and_then(KeyTrie::node) - .is_some_and(|node| node.contains_key(&key)) - } - /// Lookup `key` in the keymap to try and find a command to execute. Escape /// key cancels pending keystrokes. If there are no pending keystrokes but a /// sticky node is in use, it will be cleared. @@ -342,7 +319,7 @@ impl Keymaps { self.sticky = None; } - let first = self.state.first().unwrap_or(&key); + let first = self.state.get(0).unwrap_or(&key); let trie_node = match self.sticky { Some(ref trie) => Cow::Owned(KeyTrie::Node(trie.clone())), None => Cow::Borrowed(keymap), @@ -601,7 +578,11 @@ mod tests { MappableCommand::select_all, MappableCommand::Typable { name: "pipe".to_string(), - args: "sed -E 's/\\s+$//g'".to_string(), + args: vec!{ + "sed".to_string(), + "-E".to_string(), + "'s/\\s+$//g'".to_string() + }, doc: "".to_string(), }, }) |