Replace ProjectEntry struct with ProjectEntryId
Previously, we tracked the worktree_id and entry_id separately, but now that entry ids are unique across all worktrees this is unnecessary. Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-Authored-By: Keith Simmons <keith@the-simmons.net>
This commit is contained in:
parent
a88320dc5f
commit
0036e5c86c
9 changed files with 126 additions and 126 deletions
|
@ -10,7 +10,7 @@ use gpui::{
|
|||
AnyViewHandle, Entity, MutableAppContext, Quad, RenderContext, Task, View, ViewContext,
|
||||
ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use project::{ProjectEntry, ProjectPath};
|
||||
use project::{ProjectEntryId, ProjectPath};
|
||||
use std::{
|
||||
any::{Any, TypeId},
|
||||
cell::RefCell,
|
||||
|
@ -97,7 +97,7 @@ pub enum Event {
|
|||
}
|
||||
|
||||
pub struct Pane {
|
||||
item_views: Vec<(Option<usize>, Box<dyn ItemViewHandle>)>,
|
||||
item_views: Vec<(Option<ProjectEntryId>, Box<dyn ItemViewHandle>)>,
|
||||
active_item_index: usize,
|
||||
nav_history: Rc<RefCell<NavHistory>>,
|
||||
toolbars: HashMap<TypeId, Box<dyn ToolbarHandle>>,
|
||||
|
@ -323,9 +323,9 @@ impl Pane {
|
|||
.map(|(_, view)| view.clone())
|
||||
}
|
||||
|
||||
pub fn item_for_entry(&self, entry: ProjectEntry) -> Option<Box<dyn ItemViewHandle>> {
|
||||
pub fn item_for_entry(&self, entry_id: ProjectEntryId) -> Option<Box<dyn ItemViewHandle>> {
|
||||
self.item_views.iter().find_map(|(id, view)| {
|
||||
if *id == Some(entry.entry_id) {
|
||||
if *id == Some(entry_id) {
|
||||
Some(view.boxed_clone())
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -26,7 +26,7 @@ use log::error;
|
|||
pub use pane::*;
|
||||
pub use pane_group::*;
|
||||
use postage::prelude::Stream;
|
||||
use project::{fs, Fs, Project, ProjectEntry, ProjectPath, Worktree};
|
||||
use project::{fs, Fs, Project, ProjectEntryId, ProjectPath, Worktree};
|
||||
pub use settings::Settings;
|
||||
use sidebar::{Side, Sidebar, SidebarItemId, ToggleSidebarItem, ToggleSidebarItemFocus};
|
||||
use status_bar::StatusBar;
|
||||
|
@ -138,7 +138,7 @@ pub trait ItemView: View {
|
|||
fn navigate(&mut self, _: Box<dyn Any>, _: &mut ViewContext<Self>) {}
|
||||
fn tab_content(&self, style: &theme::Tab, cx: &AppContext) -> ElementBox;
|
||||
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
|
||||
fn project_entry(&self, cx: &AppContext) -> Option<ProjectEntry>;
|
||||
fn project_entry_id(&self, cx: &AppContext) -> Option<ProjectEntryId>;
|
||||
fn set_nav_history(&mut self, _: ItemNavHistory, _: &mut ViewContext<Self>);
|
||||
fn clone_on_split(&self, _: &mut ViewContext<Self>) -> Option<Self>
|
||||
where
|
||||
|
@ -191,7 +191,7 @@ pub trait ItemView: View {
|
|||
pub trait ItemViewHandle: 'static {
|
||||
fn tab_content(&self, style: &theme::Tab, cx: &AppContext) -> ElementBox;
|
||||
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
|
||||
fn project_entry_id(&self, cx: &AppContext) -> Option<usize>;
|
||||
fn project_entry_id(&self, cx: &AppContext) -> Option<ProjectEntryId>;
|
||||
fn boxed_clone(&self) -> Box<dyn ItemViewHandle>;
|
||||
fn set_nav_history(&self, nav_history: Rc<RefCell<NavHistory>>, cx: &mut MutableAppContext);
|
||||
fn clone_on_split(&self, cx: &mut MutableAppContext) -> Option<Box<dyn ItemViewHandle>>;
|
||||
|
@ -239,8 +239,8 @@ impl<T: ItemView> ItemViewHandle for ViewHandle<T> {
|
|||
self.read(cx).project_path(cx)
|
||||
}
|
||||
|
||||
fn project_entry_id(&self, cx: &AppContext) -> Option<usize> {
|
||||
Some(self.read(cx).project_entry(cx)?.entry_id)
|
||||
fn project_entry_id(&self, cx: &AppContext) -> Option<ProjectEntryId> {
|
||||
self.read(cx).project_entry_id(cx)
|
||||
}
|
||||
|
||||
fn boxed_clone(&self) -> Box<dyn ItemViewHandle> {
|
||||
|
@ -850,7 +850,7 @@ impl Workspace {
|
|||
|
||||
pub fn open_item_for_project_entry<T, F>(
|
||||
&mut self,
|
||||
project_entry: ProjectEntry,
|
||||
project_entry: ProjectEntryId,
|
||||
cx: &mut ViewContext<Self>,
|
||||
build_view: F,
|
||||
) -> Box<dyn ItemViewHandle>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue