aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/keymap.rs
diff options
context:
space:
mode:
authorMehdi Abedi2024-02-14 10:53:15 +0000
committerGitHub2024-02-14 10:53:15 +0000
commit4df08ddbe02f1e8d84c6aa4be810a91f83c73441 (patch)
treee7b76a3d51140e7a8b279023986fd337ac2fe447 /helix-term/src/keymap.rs
parentc59f29921da98e23525c9ff4ffa82e330310e6fe (diff)
Allow numbers as second input event (#8471)
* Make sure pending key list is empty when count handling This will allow using numbers as second key event. * count handling; add an exception for 'g' * Lookup the key event before considering a number as count * Avoid the allocation of another vec for the pending keys --------- Co-authored-by: x <x@torrent>
Diffstat (limited to 'helix-term/src/keymap.rs')
-rw-r--r--helix-term/src/keymap.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs
index d9297e08..975274ed 100644
--- a/helix-term/src/keymap.rs
+++ b/helix-term/src/keymap.rs
@@ -303,6 +303,15 @@ 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.