diff --git a/zed/src/project_panel.rs b/zed/src/project_panel.rs index c86a0927ac479a653e1a71c6aff8cdd11af6b3f7..421aa226881c2bae7b015ec8d893ed73d918aa87 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 f85829277ca8ad4e71e8d2fd28970936dc38716d..e3309e17a2c9bb8c97e4c0a3fdc7847df711a5bf 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 8bb005ed50b73e69aa674b7534d21c5e22848706..23b70d917b37e86e0fb3b6628d8d440d0c1082ab 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) }