mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +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 {
|
if epoch == self.blink_epoch && self.enabled && !self.blinking_paused {
|
||||||
self.visible = !self.visible;
|
self.visible = !self.visible;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
dbg!(cx.handle());
|
|
||||||
|
|
||||||
let epoch = self.next_blink_epoch();
|
let epoch = self.next_blink_epoch();
|
||||||
let interval = self.blink_interval;
|
let interval = self.blink_interval;
|
||||||
|
|
|
@ -1524,6 +1524,13 @@ impl MutableAppContext {
|
||||||
|
|
||||||
pub fn dispatch_keystroke(&mut self, window_id: usize, keystroke: &Keystroke) -> bool {
|
pub fn dispatch_keystroke(&mut self, window_id: usize, keystroke: &Keystroke) -> bool {
|
||||||
if let Some(focused_view_id) = self.focused_view_id(window_id) {
|
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
|
let dispatch_path = self
|
||||||
.ancestors(window_id, focused_view_id)
|
.ancestors(window_id, focused_view_id)
|
||||||
.map(|view_id| {
|
.map(|view_id| {
|
||||||
|
|
|
@ -77,10 +77,7 @@ where
|
||||||
pub enum MatchResult {
|
pub enum MatchResult {
|
||||||
None,
|
None,
|
||||||
Pending,
|
Pending,
|
||||||
Match {
|
Match(Vec<(usize, Box<dyn Action>)>),
|
||||||
view_id: usize,
|
|
||||||
action: Box<dyn Action>,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for MatchResult {
|
impl Debug for MatchResult {
|
||||||
|
@ -157,8 +154,10 @@ impl Matcher {
|
||||||
dispatch_path: Vec<(usize, Context)>,
|
dispatch_path: Vec<(usize, Context)>,
|
||||||
) -> MatchResult {
|
) -> MatchResult {
|
||||||
let mut any_pending = false;
|
let mut any_pending = false;
|
||||||
|
let mut matched_bindings = Vec::new();
|
||||||
|
|
||||||
let first_keystroke = self.pending.is_empty();
|
let first_keystroke = self.pending.is_empty();
|
||||||
|
dbg!(&dispatch_path);
|
||||||
for (view_id, context) in dispatch_path {
|
for (view_id, context) in dispatch_path {
|
||||||
if !first_keystroke && !self.pending.contains_key(&view_id) {
|
if !first_keystroke && !self.pending.contains_key(&view_id) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -185,10 +184,7 @@ impl Matcher {
|
||||||
{
|
{
|
||||||
if binding.keystrokes.len() == pending.keystrokes.len() {
|
if binding.keystrokes.len() == pending.keystrokes.len() {
|
||||||
self.pending.remove(&view_id);
|
self.pending.remove(&view_id);
|
||||||
return MatchResult::Match {
|
matched_bindings.push((view_id, binding.action.boxed_clone()));
|
||||||
view_id,
|
|
||||||
action: binding.action.boxed_clone(),
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
retain_pending = true;
|
retain_pending = true;
|
||||||
pending.context = Some(context.clone());
|
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
|
MatchResult::Pending
|
||||||
} else {
|
} else {
|
||||||
MatchResult::None
|
MatchResult::None
|
||||||
|
|
Loading…
Reference in a new issue