First round of vim tests

This commit is contained in:
Conrad Irwin
2023-12-11 14:16:25 -07:00
parent f35453caad
commit d1805d8ada
16 changed files with 938 additions and 884 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ impl KeyBinding {
{
// If the binding is completed, push it onto the matches list
if self.keystrokes.as_ref().len() == pending_keystrokes.len() {
KeyMatch::Some(self.action.boxed_clone())
KeyMatch::Some(vec![self.action.boxed_clone()])
} else {
KeyMatch::Pending
}
+9 -4
View File
@@ -54,14 +54,14 @@ impl KeystrokeMatcher {
}
let mut pending_key = None;
let mut found_actions = Vec::new();
for binding in keymap.bindings().iter().rev() {
for candidate in keystroke.match_candidates() {
self.pending_keystrokes.push(candidate.clone());
match binding.match_keystrokes(&self.pending_keystrokes, context_stack) {
KeyMatch::Some(action) => {
self.pending_keystrokes.clear();
return KeyMatch::Some(action);
KeyMatch::Some(mut actions) => {
found_actions.append(&mut actions);
}
KeyMatch::Pending => {
pending_key.get_or_insert(candidate);
@@ -72,6 +72,11 @@ impl KeystrokeMatcher {
}
}
if !found_actions.is_empty() {
self.pending_keystrokes.clear();
return KeyMatch::Some(found_actions);
}
if let Some(pending_key) = pending_key {
self.pending_keystrokes.push(pending_key);
}
@@ -101,7 +106,7 @@ impl KeystrokeMatcher {
pub enum KeyMatch {
None,
Pending,
Some(Box<dyn Action>),
Some(Vec<Box<dyn Action>>),
}
impl KeyMatch {