diff --git a/zed/src/project_panel.rs b/zed/src/project_panel.rs index c86a0927ac..421aa22688 100644 --- a/zed/src/project_panel.rs +++ b/zed/src/project_panel.rs @@ -28,8 +28,8 @@ struct EntryDetails { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct ProjectEntry { - worktree_ix: usize, - entry_id: usize, + pub worktree_ix: usize, + pub entry_id: usize, } action!(ToggleExpanded, ProjectEntry); diff --git a/zed/src/workspace.rs b/zed/src/workspace.rs index f85829277c..e3309e17a2 100644 --- a/zed/src/workspace.rs +++ b/zed/src/workspace.rs @@ -8,7 +8,7 @@ use crate::{ fs::Fs, people_panel::{JoinWorktree, LeaveWorktree, PeoplePanel, ShareWorktree, UnshareWorktree}, project::Project, - project_panel::ProjectPanel, + project_panel::{self, ProjectPanel}, rpc, settings::Settings, user, @@ -54,6 +54,14 @@ pub fn init(cx: &mut MutableAppContext) { cx.add_action(Workspace::save_active_item); cx.add_action(Workspace::debug_elements); cx.add_action(Workspace::open_new_file); + cx.add_action(|this: &mut Workspace, action: &project_panel::Open, cx| { + if let Some(worktree) = this.worktrees(cx).get(action.0.worktree_ix) { + if let Some(entry) = worktree.read(cx).entry_for_id(action.0.entry_id) { + this.open_entry((worktree.id(), entry.path.clone()), cx) + .map(|task| task.detach()); + } + } + }); cx.add_action(Workspace::toggle_sidebar_item); cx.add_action(Workspace::share_worktree); cx.add_action(Workspace::unshare_worktree); diff --git a/zed/src/worktree.rs b/zed/src/worktree.rs index 8bb005ed50..23b70d917b 100644 --- a/zed/src/worktree.rs +++ b/zed/src/worktree.rs @@ -1582,7 +1582,7 @@ impl Snapshot { }) } - fn entry_for_id(&self, id: usize) -> Option<&Entry> { + pub fn entry_for_id(&self, id: usize) -> Option<&Entry> { let entry = self.entries_by_id.get(&id, &())?; self.entry_for_path(&entry.path) }