mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Allow opening entries from project panel
This commit is contained in:
parent
e030917769
commit
67c40eb4be
3 changed files with 12 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue