From 672b4456761e9f42ded635b6c6aa325968b01b6b Mon Sep 17 00:00:00 2001 From: K Simmons Date: Thu, 27 Oct 2022 12:36:53 -0700 Subject: [PATCH] minor tweak to keymap code --- crates/gpui/src/keymap.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/keymap.rs b/crates/gpui/src/keymap.rs index 89831f2c7f..1e98c52634 100644 --- a/crates/gpui/src/keymap.rs +++ b/crates/gpui/src/keymap.rs @@ -174,6 +174,7 @@ impl Matcher { } } + // Find the bindings which map the pending keystrokes and current context for binding in self.keymap.bindings.iter().rev() { if binding.keystrokes.starts_with(&self.pending_keystrokes) && binding @@ -182,9 +183,11 @@ impl Matcher { .map(|c| c.eval(&context)) .unwrap_or(true) { + // If the binding is completed, push it onto the matches list if binding.keystrokes.len() == self.pending_keystrokes.len() { matched_bindings.push((view_id, binding.action.boxed_clone())); } else { + // Otherwise, the binding is still pending self.pending_views.insert(view_id, context.clone()); any_pending = true; } @@ -193,13 +196,11 @@ impl Matcher { } if !matched_bindings.is_empty() { - self.pending_views.clear(); - self.pending_keystrokes.clear(); MatchResult::Matches(matched_bindings) } else if any_pending { MatchResult::Pending } else { - self.pending_keystrokes.clear(); + self.clear_pending(); MatchResult::None } }