mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-24 17:28:40 +00:00
WIP: Change to matches to vec
This commit is contained in:
parent
afe9ab9d8c
commit
8d94de8eb2
3 changed files with 14 additions and 10 deletions
|
@ -71,7 +71,6 @@ impl BlinkManager {
|
|||
if epoch == self.blink_epoch && self.enabled && !self.blinking_paused {
|
||||
self.visible = !self.visible;
|
||||
cx.notify();
|
||||
dbg!(cx.handle());
|
||||
|
||||
let epoch = self.next_blink_epoch();
|
||||
let interval = self.blink_interval;
|
||||
|
|
|
@ -1524,6 +1524,13 @@ impl MutableAppContext {
|
|||
|
||||
pub fn dispatch_keystroke(&mut self, window_id: usize, keystroke: &Keystroke) -> bool {
|
||||
if let Some(focused_view_id) = self.focused_view_id(window_id) {
|
||||
// For each view in self
|
||||
// - Get it's keymap context
|
||||
// - Try to execute keybinding
|
||||
|
||||
// For us, get out dispatch path
|
||||
// - ONLY execute for that terminal path
|
||||
|
||||
let dispatch_path = self
|
||||
.ancestors(window_id, focused_view_id)
|
||||
.map(|view_id| {
|
||||
|
|
|
@ -77,10 +77,7 @@ where
|
|||
pub enum MatchResult {
|
||||
None,
|
||||
Pending,
|
||||
Match {
|
||||
view_id: usize,
|
||||
action: Box<dyn Action>,
|
||||
},
|
||||
Match(Vec<(usize, Box<dyn Action>)>),
|
||||
}
|
||||
|
||||
impl Debug for MatchResult {
|
||||
|
@ -157,8 +154,10 @@ impl Matcher {
|
|||
dispatch_path: Vec<(usize, Context)>,
|
||||
) -> MatchResult {
|
||||
let mut any_pending = false;
|
||||
let mut matched_bindings = Vec::new();
|
||||
|
||||
let first_keystroke = self.pending.is_empty();
|
||||
dbg!(&dispatch_path);
|
||||
for (view_id, context) in dispatch_path {
|
||||
if !first_keystroke && !self.pending.contains_key(&view_id) {
|
||||
continue;
|
||||
|
@ -185,10 +184,7 @@ impl Matcher {
|
|||
{
|
||||
if binding.keystrokes.len() == pending.keystrokes.len() {
|
||||
self.pending.remove(&view_id);
|
||||
return MatchResult::Match {
|
||||
view_id,
|
||||
action: binding.action.boxed_clone(),
|
||||
};
|
||||
matched_bindings.push((view_id, binding.action.boxed_clone()));
|
||||
} else {
|
||||
retain_pending = true;
|
||||
pending.context = Some(context.clone());
|
||||
|
@ -203,7 +199,9 @@ impl Matcher {
|
|||
}
|
||||
}
|
||||
|
||||
if any_pending {
|
||||
if !matched_bindings.is_empty() {
|
||||
MatchResult::Match(matched_bindings)
|
||||
} else if any_pending {
|
||||
MatchResult::Pending
|
||||
} else {
|
||||
MatchResult::None
|
||||
|
|
Loading…
Reference in a new issue