mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +00:00
minor tweak to keymap code
This commit is contained in:
parent
e02199fa2a
commit
672b445676
1 changed files with 4 additions and 3 deletions
|
@ -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() {
|
for binding in self.keymap.bindings.iter().rev() {
|
||||||
if binding.keystrokes.starts_with(&self.pending_keystrokes)
|
if binding.keystrokes.starts_with(&self.pending_keystrokes)
|
||||||
&& binding
|
&& binding
|
||||||
|
@ -182,9 +183,11 @@ impl Matcher {
|
||||||
.map(|c| c.eval(&context))
|
.map(|c| c.eval(&context))
|
||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
{
|
{
|
||||||
|
// If the binding is completed, push it onto the matches list
|
||||||
if binding.keystrokes.len() == self.pending_keystrokes.len() {
|
if binding.keystrokes.len() == self.pending_keystrokes.len() {
|
||||||
matched_bindings.push((view_id, binding.action.boxed_clone()));
|
matched_bindings.push((view_id, binding.action.boxed_clone()));
|
||||||
} else {
|
} else {
|
||||||
|
// Otherwise, the binding is still pending
|
||||||
self.pending_views.insert(view_id, context.clone());
|
self.pending_views.insert(view_id, context.clone());
|
||||||
any_pending = true;
|
any_pending = true;
|
||||||
}
|
}
|
||||||
|
@ -193,13 +196,11 @@ impl Matcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !matched_bindings.is_empty() {
|
if !matched_bindings.is_empty() {
|
||||||
self.pending_views.clear();
|
|
||||||
self.pending_keystrokes.clear();
|
|
||||||
MatchResult::Matches(matched_bindings)
|
MatchResult::Matches(matched_bindings)
|
||||||
} else if any_pending {
|
} else if any_pending {
|
||||||
MatchResult::Pending
|
MatchResult::Pending
|
||||||
} else {
|
} else {
|
||||||
self.pending_keystrokes.clear();
|
self.clear_pending();
|
||||||
MatchResult::None
|
MatchResult::None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue