Start work on a command palette

This commit is contained in:
Max Brunsfeld 2022-04-13 13:20:59 -07:00
parent 99f8466cb5
commit 4630071f58
11 changed files with 487 additions and 26 deletions

View file

@ -51,15 +51,21 @@ impl Presenter {
}
pub fn dispatch_path(&self, app: &AppContext) -> Vec<usize> {
let mut path = Vec::new();
if let Some(mut view_id) = app.focused_view_id(self.window_id) {
path.push(view_id);
while let Some(parent_id) = self.parents.get(&view_id).copied() {
path.push(parent_id);
view_id = parent_id;
}
path.reverse();
if let Some(view_id) = app.focused_view_id(self.window_id) {
self.dispatch_path_from(view_id)
} else {
Vec::new()
}
}
pub(crate) fn dispatch_path_from(&self, mut view_id: usize) -> Vec<usize> {
let mut path = Vec::new();
path.push(view_id);
while let Some(parent_id) = self.parents.get(&view_id).copied() {
path.push(parent_id);
view_id = parent_id;
}
path.reverse();
path
}