WIP
This commit is contained in:
parent
00c92ae407
commit
538a9e1392
5 changed files with 781 additions and 892 deletions
|
@ -305,42 +305,6 @@ impl<ParentV: 'static> Component<ParentV> for AnyView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Element<()> for AnyView {
|
|
||||||
type ElementState = AnyBox;
|
|
||||||
|
|
||||||
fn id(&self) -> Option<crate::ElementId> {
|
|
||||||
Some(ElementId::View(self.0.entity_id()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn initialize(
|
|
||||||
&mut self,
|
|
||||||
_: &mut (),
|
|
||||||
_: Option<Self::ElementState>,
|
|
||||||
cx: &mut ViewContext<()>,
|
|
||||||
) -> Self::ElementState {
|
|
||||||
self.0.initialize(cx)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn layout(
|
|
||||||
&mut self,
|
|
||||||
_: &mut (),
|
|
||||||
element: &mut Self::ElementState,
|
|
||||||
cx: &mut ViewContext<()>,
|
|
||||||
) -> LayoutId {
|
|
||||||
self.0.layout(element, cx)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn paint(
|
|
||||||
&mut self,
|
|
||||||
bounds: Bounds<Pixels>,
|
|
||||||
_: &mut (),
|
|
||||||
element: &mut AnyBox,
|
|
||||||
cx: &mut ViewContext<()>,
|
|
||||||
) {
|
|
||||||
self.0.paint(bounds, element, cx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Debug for AnyView {
|
impl std::fmt::Debug for AnyView {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
self.0.debug(f)
|
self.0.debug(f)
|
||||||
|
@ -376,7 +340,7 @@ impl<ParentV: 'static> Element<ParentV> for EraseAnyViewState<ParentV> {
|
||||||
type ElementState = AnyBox;
|
type ElementState = AnyBox;
|
||||||
|
|
||||||
fn id(&self) -> Option<ElementId> {
|
fn id(&self) -> Option<ElementId> {
|
||||||
Element::id(&self.view)
|
Some(self.view.0.entity_id().into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize(
|
fn initialize(
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// use crate::{AutosaveSetting, DelayedDebouncedEditAction, WorkspaceSettings};
|
// use crate::{AutosaveSetting, DelayedDebouncedEditAction, WorkspaceSettings};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use client2::{
|
use client2::{
|
||||||
proto::{self, PeerId, ViewId},
|
proto::{self, PeerId},
|
||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
use settings2::Settings;
|
use settings2::Settings;
|
||||||
|
@ -98,12 +98,12 @@ pub struct BreadcrumbText {
|
||||||
pub highlights: Option<Vec<(Range<usize>, HighlightStyle)>>,
|
pub highlights: Option<Vec<(Range<usize>, HighlightStyle)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Item: EventEmitter + Sized {
|
pub trait Item: Render + EventEmitter + Send {
|
||||||
// fn deactivated(&mut self, _: &mut ViewContext<Self>) {}
|
fn deactivated(&mut self, _: &mut ViewContext<Self>) {}
|
||||||
// fn workspace_deactivated(&mut self, _: &mut ViewContext<Self>) {}
|
fn workspace_deactivated(&mut self, _: &mut ViewContext<Self>) {}
|
||||||
// fn navigate(&mut self, _: Box<dyn Any>, _: &mut ViewContext<Self>) -> bool {
|
fn navigate(&mut self, _: Box<dyn Any>, _: &mut ViewContext<Self>) -> bool {
|
||||||
// false
|
false
|
||||||
// }
|
}
|
||||||
fn tab_tooltip_text(&self, _: &AppContext) -> Option<SharedString> {
|
fn tab_tooltip_text(&self, _: &AppContext) -> Option<SharedString> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -117,53 +117,53 @@ pub trait Item: EventEmitter + Sized {
|
||||||
fn is_singleton(&self, _cx: &AppContext) -> bool {
|
fn is_singleton(&self, _cx: &AppContext) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
// fn set_nav_history(&mut self, _: ItemNavHistory, _: &mut ViewContext<Self>) {}
|
fn set_nav_history(&mut self, _: ItemNavHistory, _: &mut ViewContext<Self>) {}
|
||||||
fn clone_on_split(&self, _workspace_id: WorkspaceId, _: &mut ViewContext<Self>) -> Option<Self>
|
fn clone_on_split(
|
||||||
|
&self,
|
||||||
|
_workspace_id: WorkspaceId,
|
||||||
|
_: &mut ViewContext<Self>,
|
||||||
|
) -> Option<View<Self>>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
// fn is_dirty(&self, _: &AppContext) -> bool {
|
fn is_dirty(&self, _: &AppContext) -> bool {
|
||||||
// false
|
false
|
||||||
// }
|
}
|
||||||
// fn has_conflict(&self, _: &AppContext) -> bool {
|
fn has_conflict(&self, _: &AppContext) -> bool {
|
||||||
// false
|
false
|
||||||
// }
|
}
|
||||||
// fn can_save(&self, _cx: &AppContext) -> bool {
|
fn can_save(&self, _cx: &AppContext) -> bool {
|
||||||
// false
|
false
|
||||||
// }
|
}
|
||||||
// fn save(
|
fn save(&mut self, _project: Model<Project>, _cx: &mut ViewContext<Self>) -> Task<Result<()>> {
|
||||||
// &mut self,
|
unimplemented!("save() must be implemented if can_save() returns true")
|
||||||
// _project: Model<Project>,
|
}
|
||||||
// _cx: &mut ViewContext<Self>,
|
fn save_as(
|
||||||
// ) -> Task<Result<()>> {
|
&mut self,
|
||||||
// unimplemented!("save() must be implemented if can_save() returns true")
|
_project: Model<Project>,
|
||||||
// }
|
_abs_path: PathBuf,
|
||||||
// fn save_as(
|
_cx: &mut ViewContext<Self>,
|
||||||
// &mut self,
|
) -> Task<Result<()>> {
|
||||||
// _project: Model<Project>,
|
unimplemented!("save_as() must be implemented if can_save() returns true")
|
||||||
// _abs_path: PathBuf,
|
}
|
||||||
// _cx: &mut ViewContext<Self>,
|
fn reload(
|
||||||
// ) -> Task<Result<()>> {
|
&mut self,
|
||||||
// unimplemented!("save_as() must be implemented if can_save() returns true")
|
_project: Model<Project>,
|
||||||
// }
|
_cx: &mut ViewContext<Self>,
|
||||||
// fn reload(
|
) -> Task<Result<()>> {
|
||||||
// &mut self,
|
unimplemented!("reload() must be implemented if can_save() returns true")
|
||||||
// _project: Model<Project>,
|
}
|
||||||
// _cx: &mut ViewContext<Self>,
|
|
||||||
// ) -> Task<Result<()>> {
|
|
||||||
// unimplemented!("reload() must be implemented if can_save() returns true")
|
|
||||||
// }
|
|
||||||
fn to_item_events(_event: &Self::Event) -> SmallVec<[ItemEvent; 2]> {
|
fn to_item_events(_event: &Self::Event) -> SmallVec<[ItemEvent; 2]> {
|
||||||
SmallVec::new()
|
SmallVec::new()
|
||||||
}
|
}
|
||||||
// fn should_close_item_on_event(_: &Self::Event) -> bool {
|
fn should_close_item_on_event(_: &Self::Event) -> bool {
|
||||||
// false
|
false
|
||||||
// }
|
}
|
||||||
// fn should_update_tab_on_event(_: &Self::Event) -> bool {
|
fn should_update_tab_on_event(_: &Self::Event) -> bool {
|
||||||
// false
|
false
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn act_as_type<'a>(
|
// fn act_as_type<'a>(
|
||||||
// &'a self,
|
// &'a self,
|
||||||
|
@ -178,41 +178,41 @@ pub trait Item: EventEmitter + Sized {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// fn as_searchable(&self, _: &View<Self>) -> Option<Box<dyn SearchableItemHandle>> {
|
fn as_searchable(&self, _: &View<Self>) -> Option<Box<dyn SearchableItemHandle>> {
|
||||||
// None
|
None
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn breadcrumb_location(&self) -> ToolbarItemLocation {
|
fn breadcrumb_location(&self) -> ToolbarItemLocation {
|
||||||
// ToolbarItemLocation::Hidden
|
ToolbarItemLocation::Hidden
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<BreadcrumbText>> {
|
fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<BreadcrumbText>> {
|
||||||
// None
|
None
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn added_to_workspace(&mut self, _workspace: &mut Workspace, _cx: &mut ViewContext<Self>) {}
|
fn added_to_workspace(&mut self, _workspace: &mut Workspace, _cx: &mut ViewContext<Self>) {}
|
||||||
|
|
||||||
// fn serialized_item_kind() -> Option<&'static str> {
|
fn serialized_item_kind() -> Option<&'static str> {
|
||||||
// None
|
None
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn deserialize(
|
fn deserialize(
|
||||||
// _project: Model<Project>,
|
_project: Model<Project>,
|
||||||
// _workspace: WeakViewHandle<Workspace>,
|
_workspace: WeakView<Workspace>,
|
||||||
// _workspace_id: WorkspaceId,
|
_workspace_id: WorkspaceId,
|
||||||
// _item_id: ItemId,
|
_item_id: ItemId,
|
||||||
// _cx: &mut ViewContext<Pane>,
|
_cx: &mut ViewContext<Pane>,
|
||||||
// ) -> Task<Result<View<Self>>> {
|
) -> Task<Result<View<Self>>> {
|
||||||
// unimplemented!(
|
unimplemented!(
|
||||||
// "deserialize() must be implemented if serialized_item_kind() returns Some(_)"
|
"deserialize() must be implemented if serialized_item_kind() returns Some(_)"
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
// fn show_toolbar(&self) -> bool {
|
fn show_toolbar(&self) -> bool {
|
||||||
// true
|
true
|
||||||
// }
|
}
|
||||||
// fn pixel_position_of_cursor(&self, _: &AppContext) -> Option<Vector2F> {
|
fn pixel_position_of_cursor(&self, _: &AppContext) -> Option<Point<Pixels>> {
|
||||||
// None
|
None
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -229,18 +229,19 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use gpui2::{
|
use gpui2::{
|
||||||
AnyElement, AnyWindowHandle, AppContext, EventEmitter, HighlightStyle, Model, Pixels, Point,
|
AnyElement, AnyView, AnyWindowHandle, AppContext, EventEmitter, HighlightStyle, Model, Pixels,
|
||||||
SharedString, Task, View, ViewContext, WindowContext,
|
Point, Render, SharedString, Task, View, ViewContext, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use project2::{Project, ProjectEntryId, ProjectPath};
|
use project2::{Project, ProjectEntryId, ProjectPath};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
pane::{self, Pane},
|
pane::{self, Pane},
|
||||||
|
persistence::model::ItemId,
|
||||||
searchable::SearchableItemHandle,
|
searchable::SearchableItemHandle,
|
||||||
workspace_settings::{AutosaveSetting, WorkspaceSettings},
|
workspace_settings::{AutosaveSetting, WorkspaceSettings},
|
||||||
DelayedDebouncedEditAction, FollowableItemBuilders, ToolbarItemLocation, Workspace,
|
DelayedDebouncedEditAction, FollowableItemBuilders, ItemNavHistory, ToolbarItemLocation,
|
||||||
WorkspaceId,
|
ViewId, Workspace, WorkspaceId,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait ItemHandle: 'static + Send {
|
pub trait ItemHandle: 'static + Send {
|
||||||
|
@ -275,7 +276,7 @@ pub trait ItemHandle: 'static + Send {
|
||||||
fn navigate(&self, data: Box<dyn Any>, cx: &mut WindowContext) -> bool;
|
fn navigate(&self, data: Box<dyn Any>, cx: &mut WindowContext) -> bool;
|
||||||
fn id(&self) -> usize;
|
fn id(&self) -> usize;
|
||||||
fn window(&self) -> AnyWindowHandle;
|
fn window(&self) -> AnyWindowHandle;
|
||||||
// fn as_any(&self) -> &AnyView; todo!()
|
fn to_any(&self) -> AnyView;
|
||||||
fn is_dirty(&self, cx: &AppContext) -> bool;
|
fn is_dirty(&self, cx: &AppContext) -> bool;
|
||||||
fn has_conflict(&self, cx: &AppContext) -> bool;
|
fn has_conflict(&self, cx: &AppContext) -> bool;
|
||||||
fn can_save(&self, cx: &AppContext) -> bool;
|
fn can_save(&self, cx: &AppContext) -> bool;
|
||||||
|
@ -302,10 +303,10 @@ pub trait ItemHandle: 'static + Send {
|
||||||
fn pixel_position_of_cursor(&self, cx: &AppContext) -> Option<Point<Pixels>>;
|
fn pixel_position_of_cursor(&self, cx: &AppContext) -> Option<Point<Pixels>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait WeakItemHandle {
|
pub trait WeakItemHandle: Send {
|
||||||
fn id(&self) -> usize;
|
fn id(&self) -> usize;
|
||||||
fn window(&self) -> AnyWindowHandle;
|
fn window(&self) -> AnyWindowHandle;
|
||||||
fn upgrade(&self, cx: &AppContext) -> Option<Box<dyn ItemHandle>>;
|
fn upgrade(&self) -> Option<Box<dyn ItemHandle>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo!()
|
// todo!()
|
||||||
|
@ -399,10 +400,8 @@ impl<T: Item> ItemHandle for View<T> {
|
||||||
workspace_id: WorkspaceId,
|
workspace_id: WorkspaceId,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
) -> Option<Box<dyn ItemHandle>> {
|
) -> Option<Box<dyn ItemHandle>> {
|
||||||
self.update(cx, |item, cx| {
|
self.update(cx, |item, cx| item.clone_on_split(workspace_id, cx))
|
||||||
cx.add_option_view(|cx| item.clone_on_split(workspace_id, cx))
|
.map(|handle| Box::new(handle) as Box<dyn ItemHandle>)
|
||||||
})
|
|
||||||
.map(|handle| Box::new(handle) as Box<dyn ItemHandle>)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn added_to_pane(
|
fn added_to_pane(
|
||||||
|
@ -447,7 +446,7 @@ impl<T: Item> ItemHandle for View<T> {
|
||||||
let pane = if let Some(pane) = workspace
|
let pane = if let Some(pane) = workspace
|
||||||
.panes_by_item
|
.panes_by_item
|
||||||
.get(&item.id())
|
.get(&item.id())
|
||||||
.and_then(|pane| pane.upgrade(cx))
|
.and_then(|pane| pane.upgrade())
|
||||||
{
|
{
|
||||||
pane
|
pane
|
||||||
} else {
|
} else {
|
||||||
|
@ -570,10 +569,9 @@ impl<T: Item> ItemHandle for View<T> {
|
||||||
// AnyViewHandle::window(self)
|
// AnyViewHandle::window(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo!()
|
fn to_any(&self) -> AnyView {
|
||||||
// fn as_any(&self) -> &AnyViewHandle {
|
self.clone().into_any()
|
||||||
// self
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
fn is_dirty(&self, cx: &AppContext) -> bool {
|
fn is_dirty(&self, cx: &AppContext) -> bool {
|
||||||
self.read(cx).is_dirty(cx)
|
self.read(cx).is_dirty(cx)
|
||||||
|
@ -652,17 +650,17 @@ impl<T: Item> ItemHandle for View<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl From<Box<dyn ItemHandle>> for AnyViewHandle {
|
impl From<Box<dyn ItemHandle>> for AnyView {
|
||||||
// fn from(val: Box<dyn ItemHandle>) -> Self {
|
fn from(val: Box<dyn ItemHandle>) -> Self {
|
||||||
// val.as_any().clone()
|
val.to_any()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// impl From<&Box<dyn ItemHandle>> for AnyViewHandle {
|
impl From<&Box<dyn ItemHandle>> for AnyView {
|
||||||
// fn from(val: &Box<dyn ItemHandle>) -> Self {
|
fn from(val: &Box<dyn ItemHandle>) -> Self {
|
||||||
// val.as_any().clone()
|
val.to_any()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
impl Clone for Box<dyn ItemHandle> {
|
impl Clone for Box<dyn ItemHandle> {
|
||||||
fn clone(&self) -> Box<dyn ItemHandle> {
|
fn clone(&self) -> Box<dyn ItemHandle> {
|
||||||
|
@ -670,19 +668,19 @@ impl Clone for Box<dyn ItemHandle> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl<T: Item> WeakItemHandle for WeakViewHandle<T> {
|
impl<T: Item> WeakItemHandle for WeakView<T> {
|
||||||
// fn id(&self) -> usize {
|
fn id(&self) -> usize {
|
||||||
// self.id()
|
self.id()
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn window(&self) -> AnyWindowHandle {
|
fn window(&self) -> AnyWindowHandle {
|
||||||
// self.window()
|
self.window()
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn upgrade(&self, cx: &AppContext) -> Option<Box<dyn ItemHandle>> {
|
fn upgrade(&self) -> Option<Box<dyn ItemHandle>> {
|
||||||
// self.upgrade(cx).map(|v| Box::new(v) as Box<dyn ItemHandle>)
|
self.upgrade().map(|v| Box::new(v) as Box<dyn ItemHandle>)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub trait ProjectItem: Item {
|
pub trait ProjectItem: Item {
|
||||||
type Item: project2::Item;
|
type Item: project2::Item;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@ use db2::sqlez::{
|
||||||
bindable::{Bind, Column, StaticColumnCount},
|
bindable::{Bind, Column, StaticColumnCount},
|
||||||
statement::Statement,
|
statement::Statement,
|
||||||
};
|
};
|
||||||
use gpui2::{AsyncAppContext, Handle, Task, View, WeakView, WindowBounds};
|
use gpui2::{AsyncAppContext, AsyncWindowContext, Handle, Task, View, WeakView, WindowBounds};
|
||||||
use project2::Project;
|
use project2::Project;
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
@ -154,7 +154,7 @@ impl SerializedPaneGroup {
|
||||||
project: &Handle<Project>,
|
project: &Handle<Project>,
|
||||||
workspace_id: WorkspaceId,
|
workspace_id: WorkspaceId,
|
||||||
workspace: &WeakView<Workspace>,
|
workspace: &WeakView<Workspace>,
|
||||||
cx: &mut AsyncAppContext,
|
cx: &mut AsyncWindowContext,
|
||||||
) -> Option<(Member, Option<View<Pane>>, Vec<Option<Box<dyn ItemHandle>>>)> {
|
) -> Option<(Member, Option<View<Pane>>, Vec<Option<Box<dyn ItemHandle>>>)> {
|
||||||
match self {
|
match self {
|
||||||
SerializedPaneGroup::Group {
|
SerializedPaneGroup::Group {
|
||||||
|
|
|
@ -11,65 +11,30 @@ mod toolbar;
|
||||||
mod workspace_settings;
|
mod workspace_settings;
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
// use call2::ActiveCall;
|
use client2::{
|
||||||
// use client2::{
|
proto::{self, PeerId},
|
||||||
// proto::{self, PeerId},
|
Client, UserStore,
|
||||||
// Client, Status, TypedEnvelope, UserStore,
|
};
|
||||||
// };
|
use collections::{HashMap, HashSet};
|
||||||
// use collections::{hash_map, HashMap, HashSet};
|
use futures::{channel::oneshot, FutureExt};
|
||||||
// use futures::{
|
use gpui2::{
|
||||||
// channel::{mpsc, oneshot},
|
AnyModel, AnyView, AppContext, AsyncAppContext, DisplayId, MainThread, Model, Task, View,
|
||||||
// future::try_join_all,
|
ViewContext, VisualContext, WeakModel, WeakView, WindowBounds, WindowHandle, WindowOptions,
|
||||||
// FutureExt, StreamExt,
|
};
|
||||||
// };
|
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem};
|
||||||
// use gpui2::{
|
use language2::LanguageRegistry;
|
||||||
// actions,
|
use node_runtime::NodeRuntime;
|
||||||
// elements::*,
|
|
||||||
// geometry::{
|
|
||||||
// rect::RectF,
|
|
||||||
// vector::{vec2f, Vector2F},
|
|
||||||
// },
|
|
||||||
// impl_actions,
|
|
||||||
// platform::{
|
|
||||||
// CursorStyle, ModifiersChangedEvent, MouseButton, PathPromptOptions, Platform, PromptLevel,
|
|
||||||
// WindowBounds, WindowOptions,
|
|
||||||
// },
|
|
||||||
// AnyModelHandle, AnyViewHandle, AnyWeakViewHandle, AnyWindowHandle, AppContext, AsyncAppContext,
|
|
||||||
// Entity, ModelContext, ModelHandle, SizeConstraint, Subscription, Task, View, ViewContext,
|
|
||||||
// View, WeakViewHandle, WindowContext, WindowHandle,
|
|
||||||
// };
|
|
||||||
// use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem};
|
|
||||||
// use itertools::Itertools;
|
|
||||||
// use language2::{LanguageRegistry, Rope};
|
|
||||||
// use node_runtime::NodeRuntime;// //
|
|
||||||
|
|
||||||
use futures::channel::oneshot;
|
|
||||||
// use crate::{
|
|
||||||
// notifications::{simple_message_notification::MessageNotification, NotificationTracker},
|
|
||||||
// persistence::model::{
|
|
||||||
// DockData, DockStructure, SerializedPane, SerializedPaneGroup, SerializedWorkspace,
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
// use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle};
|
|
||||||
// use lazy_static::lazy_static;
|
|
||||||
// use notifications::{NotificationHandle, NotifyResultExt};
|
|
||||||
pub use pane::*;
|
pub use pane::*;
|
||||||
pub use pane_group::*;
|
pub use pane_group::*;
|
||||||
// use persistence::{model::SerializedItem, DB};
|
use project2::{Project, ProjectEntryId, ProjectPath, Worktree};
|
||||||
// pub use persistence::{
|
use std::{
|
||||||
// model::{ItemId, WorkspaceLocation},
|
any::TypeId,
|
||||||
// WorkspaceDb, DB as WORKSPACE_DB,
|
path::{Path, PathBuf},
|
||||||
// };
|
sync::{atomic::AtomicUsize, Arc},
|
||||||
// use postage::prelude::Stream;
|
time::Duration,
|
||||||
// use project::{Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId};
|
};
|
||||||
// use serde::Deserialize;
|
|
||||||
// use shared_screen::SharedScreen;
|
|
||||||
// use status_bar::StatusBar;
|
|
||||||
// pub use status_bar::StatusItemView;
|
|
||||||
// use theme::{Theme, ThemeSettings};
|
|
||||||
pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
|
pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
|
||||||
// use util::ResultExt;
|
use util::ResultExt;
|
||||||
// pub use workspace_settings::{AutosaveSetting, GitGutterSetting, WorkspaceSettings};
|
|
||||||
|
|
||||||
// lazy_static! {
|
// lazy_static! {
|
||||||
// static ref ZED_WINDOW_SIZE: Option<Vector2F> = env::var("ZED_WINDOW_SIZE")
|
// static ref ZED_WINDOW_SIZE: Option<Vector2F> = env::var("ZED_WINDOW_SIZE")
|
||||||
|
@ -367,13 +332,12 @@ pub type WorkspaceId = i64;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
type ProjectItemBuilders =
|
type ProjectItemBuilders =
|
||||||
HashMap<TypeId, fn(Handle<Project>, AnyHandle, &mut ViewContext<Pane>) -> Box<dyn ItemHandle>>;
|
HashMap<TypeId, fn(Model<Project>, AnyModel, &mut ViewContext<Pane>) -> Box<dyn ItemHandle>>;
|
||||||
pub fn register_project_item<I: ProjectItem>(cx: &mut AppContext) {
|
pub fn register_project_item<I: ProjectItem>(cx: &mut AppContext) {
|
||||||
cx.update_default_global(|builders: &mut ProjectItemBuilders, _| {
|
let builders = cx.default_global::<ProjectItemBuilders>();
|
||||||
builders.insert(TypeId::of::<I::Item>(), |project, model, cx| {
|
builders.insert(TypeId::of::<I::Item>(), |project, model, cx| {
|
||||||
let item = model.downcast::<I::Item>().unwrap();
|
let item = model.downcast::<I::Item>().unwrap();
|
||||||
Box::new(cx.add_view(|cx| I::for_project_item(project, item, cx)))
|
Box::new(cx.build_view(|cx| I::for_project_item(project, item, cx)))
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,26 +356,25 @@ type FollowableItemBuilders = HashMap<
|
||||||
),
|
),
|
||||||
>;
|
>;
|
||||||
pub fn register_followable_item<I: FollowableItem>(cx: &mut AppContext) {
|
pub fn register_followable_item<I: FollowableItem>(cx: &mut AppContext) {
|
||||||
cx.update_default_global(|builders: &mut FollowableItemBuilders, _| {
|
let builders = cx.default_global::<FollowableItemBuilders>();
|
||||||
builders.insert(
|
builders.insert(
|
||||||
TypeId::of::<I>(),
|
TypeId::of::<I>(),
|
||||||
(
|
(
|
||||||
|pane, workspace, id, state, cx| {
|
|pane, workspace, id, state, cx| {
|
||||||
I::from_state_proto(pane, workspace, id, state, cx).map(|task| {
|
I::from_state_proto(pane, workspace, id, state, cx).map(|task| {
|
||||||
cx.foreground()
|
cx.executor()
|
||||||
.spawn(async move { Ok(Box::new(task.await?) as Box<_>) })
|
.spawn(async move { Ok(Box::new(task.await?) as Box<_>) })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|this| Box::new(this.clone().downcast::<I>().unwrap()),
|
|this| Box::new(this.clone().downcast::<I>().unwrap()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ItemDeserializers = HashMap<
|
type ItemDeserializers = HashMap<
|
||||||
Arc<str>,
|
Arc<str>,
|
||||||
fn(
|
fn(
|
||||||
Handle<Project>,
|
Model<Project>,
|
||||||
WeakView<Workspace>,
|
WeakView<Workspace>,
|
||||||
WorkspaceId,
|
WorkspaceId,
|
||||||
ItemId,
|
ItemId,
|
||||||
|
@ -436,18 +399,18 @@ pub fn register_deserializable_item<I: Item>(cx: &mut AppContext) {
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
pub languages: Arc<LanguageRegistry>,
|
pub languages: Arc<LanguageRegistry>,
|
||||||
pub client: Arc<Client>,
|
pub client: Arc<Client>,
|
||||||
pub user_store: Handle<UserStore>,
|
pub user_store: Model<UserStore>,
|
||||||
pub workspace_store: Handle<WorkspaceStore>,
|
pub workspace_store: Model<WorkspaceStore>,
|
||||||
pub fs: Arc<dyn fs2::Fs>,
|
pub fs: Arc<dyn fs2::Fs>,
|
||||||
pub build_window_options:
|
pub build_window_options:
|
||||||
fn(Option<WindowBounds>, Option<DisplayId>, &MainThread<AppContext>) -> WindowOptions,
|
fn(Option<WindowBounds>, Option<DisplayId>, &MainThread<AppContext>) -> WindowOptions,
|
||||||
pub initialize_workspace:
|
pub initialize_workspace:
|
||||||
fn(WeakHandle<Workspace>, bool, Arc<AppState>, AsyncAppContext) -> Task<anyhow::Result<()>>,
|
fn(WeakModel<Workspace>, bool, Arc<AppState>, AsyncAppContext) -> Task<anyhow::Result<()>>,
|
||||||
pub node_runtime: Arc<dyn NodeRuntime>,
|
pub node_runtime: Arc<dyn NodeRuntime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WorkspaceStore {
|
pub struct WorkspaceStore {
|
||||||
workspaces: HashSet<WeakHandle<Workspace>>,
|
workspaces: HashSet<WeakModel<Workspace>>,
|
||||||
followers: Vec<Follower>,
|
followers: Vec<Follower>,
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
_subscriptions: Vec<client2::Subscription>,
|
_subscriptions: Vec<client2::Subscription>,
|
||||||
|
@ -520,7 +483,7 @@ impl DelayedDebouncedEditAction {
|
||||||
|
|
||||||
let previous_task = self.task.take();
|
let previous_task = self.task.take();
|
||||||
self.task = Some(cx.spawn(|workspace, mut cx| async move {
|
self.task = Some(cx.spawn(|workspace, mut cx| async move {
|
||||||
let mut timer = cx.background().timer(delay).fuse();
|
let mut timer = cx.executor().timer(delay).fuse();
|
||||||
if let Some(previous_task) = previous_task {
|
if let Some(previous_task) = previous_task {
|
||||||
previous_task.await;
|
previous_task.await;
|
||||||
}
|
}
|
||||||
|
@ -540,13 +503,13 @@ impl DelayedDebouncedEditAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub enum Event {
|
pub enum Event {
|
||||||
// PaneAdded(View<Pane>),
|
PaneAdded(View<Pane>),
|
||||||
// ContactRequestedJoin(u64),
|
ContactRequestedJoin(u64),
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub struct Workspace {
|
pub struct Workspace {
|
||||||
weak_self: WeakHandle<Self>,
|
weak_self: WeakView<Self>,
|
||||||
// modal: Option<ActiveModal>,
|
// modal: Option<ActiveModal>,
|
||||||
// zoomed: Option<AnyWeakViewHandle>,
|
// zoomed: Option<AnyWeakViewHandle>,
|
||||||
// zoomed_position: Option<DockPosition>,
|
// zoomed_position: Option<DockPosition>,
|
||||||
|
@ -555,16 +518,16 @@ pub struct Workspace {
|
||||||
// bottom_dock: View<Dock>,
|
// bottom_dock: View<Dock>,
|
||||||
// right_dock: View<Dock>,
|
// right_dock: View<Dock>,
|
||||||
panes: Vec<View<Pane>>,
|
panes: Vec<View<Pane>>,
|
||||||
// panes_by_item: HashMap<usize, WeakViewHandle<Pane>>,
|
panes_by_item: HashMap<usize, WeakView<Pane>>,
|
||||||
// active_pane: View<Pane>,
|
// active_pane: View<Pane>,
|
||||||
last_active_center_pane: Option<WeakView<Pane>>,
|
last_active_center_pane: Option<WeakView<Pane>>,
|
||||||
// last_active_view_id: Option<proto::ViewId>,
|
// last_active_view_id: Option<proto::ViewId>,
|
||||||
// status_bar: View<StatusBar>,
|
// status_bar: View<StatusBar>,
|
||||||
// titlebar_item: Option<AnyViewHandle>,
|
// titlebar_item: Option<AnyViewHandle>,
|
||||||
// notifications: Vec<(TypeId, usize, Box<dyn NotificationHandle>)>,
|
// notifications: Vec<(TypeId, usize, Box<dyn NotificationHandle>)>,
|
||||||
project: Handle<Project>,
|
project: Model<Project>,
|
||||||
// follower_states: HashMap<View<Pane>, FollowerState>,
|
// follower_states: HashMap<View<Pane>, FollowerState>,
|
||||||
// last_leaders_by_pane: HashMap<WeakViewHandle<Pane>, PeerId>,
|
// last_leaders_by_pane: HashMap<WeakView<Pane>, PeerId>,
|
||||||
// window_edited: bool,
|
// window_edited: bool,
|
||||||
// active_call: Option<(ModelHandle<ActiveCall>, Vec<Subscription>)>,
|
// active_call: Option<(ModelHandle<ActiveCall>, Vec<Subscription>)>,
|
||||||
// leader_updates_tx: mpsc::UnboundedSender<(PeerId, proto::UpdateFollowers)>,
|
// leader_updates_tx: mpsc::UnboundedSender<(PeerId, proto::UpdateFollowers)>,
|
||||||
|
@ -574,7 +537,7 @@ pub struct Workspace {
|
||||||
// _apply_leader_updates: Task<Result<()>>,
|
// _apply_leader_updates: Task<Result<()>>,
|
||||||
// _observe_current_user: Task<Result<()>>,
|
// _observe_current_user: Task<Result<()>>,
|
||||||
// _schedule_serialize: Option<Task<()>>,
|
// _schedule_serialize: Option<Task<()>>,
|
||||||
// pane_history_timestamp: Arc<AtomicUsize>,
|
pane_history_timestamp: Arc<AtomicUsize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct ActiveModal {
|
// struct ActiveModal {
|
||||||
|
@ -582,11 +545,11 @@ pub struct Workspace {
|
||||||
// previously_focused_view_id: Option<usize>,
|
// previously_focused_view_id: Option<usize>,
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
// pub struct ViewId {
|
pub struct ViewId {
|
||||||
// pub creator: PeerId,
|
pub creator: PeerId,
|
||||||
// pub id: u64,
|
pub id: u64,
|
||||||
// }
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct FollowerState {
|
struct FollowerState {
|
||||||
|
@ -595,7 +558,7 @@ struct FollowerState {
|
||||||
items_by_leader_view_id: HashMap<ViewId, Box<dyn FollowableItemHandle>>,
|
items_by_leader_view_id: HashMap<ViewId, Box<dyn FollowableItemHandle>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// enum WorkspaceBounds {}
|
enum WorkspaceBounds {}
|
||||||
|
|
||||||
impl Workspace {
|
impl Workspace {
|
||||||
// pub fn new(
|
// pub fn new(
|
||||||
|
@ -799,7 +762,7 @@ impl Workspace {
|
||||||
// requesting_window: Option<WindowHandle<Workspace>>,
|
// requesting_window: Option<WindowHandle<Workspace>>,
|
||||||
// cx: &mut AppContext,
|
// cx: &mut AppContext,
|
||||||
// ) -> Task<(
|
// ) -> Task<(
|
||||||
// WeakViewHandle<Workspace>,
|
// WeakView<Workspace>,
|
||||||
// Vec<Option<Result<Box<dyn ItemHandle>, anyhow::Error>>>,
|
// Vec<Option<Result<Box<dyn ItemHandle>, anyhow::Error>>>,
|
||||||
// )> {
|
// )> {
|
||||||
// let project_handle = Project::local(
|
// let project_handle = Project::local(
|
||||||
|
@ -927,21 +890,21 @@ impl Workspace {
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn weak_handle(&self) -> WeakViewHandle<Self> {
|
pub fn weak_handle(&self) -> WeakView<Self> {
|
||||||
// self.weak_self.clone()
|
self.weak_self.clone()
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn left_dock(&self) -> &View<Dock> {
|
// pub fn left_dock(&self) -> &View<Dock> {
|
||||||
// &self.left_dock
|
// &self.left_dock
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn bottom_dock(&self) -> &View<Dock> {
|
// pub fn bottom_dock(&self) -> &View<Dock> {
|
||||||
// &self.bottom_dock
|
// &self.bottom_dock
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn right_dock(&self) -> &View<Dock> {
|
// pub fn right_dock(&self) -> &View<Dock> {
|
||||||
// &self.right_dock
|
// &self.right_dock
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn add_panel<T: Panel>(&mut self, panel: View<T>, cx: &mut ViewContext<Self>)
|
// pub fn add_panel<T: Panel>(&mut self, panel: View<T>, cx: &mut ViewContext<Self>)
|
||||||
// where
|
// where
|
||||||
|
@ -1038,15 +1001,15 @@ impl Workspace {
|
||||||
// &self.status_bar
|
// &self.status_bar
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn app_state(&self) -> &Arc<AppState> {
|
pub fn app_state(&self) -> &Arc<AppState> {
|
||||||
// &self.app_state
|
&self.app_state
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn user_store(&self) -> &ModelHandle<UserStore> {
|
pub fn user_store(&self) -> &Model<UserStore> {
|
||||||
// &self.app_state.user_store
|
&self.app_state.user_store
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub fn project(&self) -> &Handle<Project> {
|
pub fn project(&self) -> &Model<Project> {
|
||||||
&self.project
|
&self.project
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1108,7 +1071,7 @@ impl Workspace {
|
||||||
|
|
||||||
// fn navigate_history(
|
// fn navigate_history(
|
||||||
// &mut self,
|
// &mut self,
|
||||||
// pane: WeakViewHandle<Pane>,
|
// pane: WeakView<Pane>,
|
||||||
// mode: NavigationMode,
|
// mode: NavigationMode,
|
||||||
// cx: &mut ViewContext<Workspace>,
|
// cx: &mut ViewContext<Workspace>,
|
||||||
// ) -> Task<Result<()>> {
|
// ) -> Task<Result<()>> {
|
||||||
|
@ -1193,7 +1156,7 @@ impl Workspace {
|
||||||
|
|
||||||
// pub fn go_back(
|
// pub fn go_back(
|
||||||
// &mut self,
|
// &mut self,
|
||||||
// pane: WeakViewHandle<Pane>,
|
// pane: WeakView<Pane>,
|
||||||
// cx: &mut ViewContext<Workspace>,
|
// cx: &mut ViewContext<Workspace>,
|
||||||
// ) -> Task<Result<()>> {
|
// ) -> Task<Result<()>> {
|
||||||
// self.navigate_history(pane, NavigationMode::GoingBack, cx)
|
// self.navigate_history(pane, NavigationMode::GoingBack, cx)
|
||||||
|
@ -1201,7 +1164,7 @@ impl Workspace {
|
||||||
|
|
||||||
// pub fn go_forward(
|
// pub fn go_forward(
|
||||||
// &mut self,
|
// &mut self,
|
||||||
// pane: WeakViewHandle<Pane>,
|
// pane: WeakView<Pane>,
|
||||||
// cx: &mut ViewContext<Workspace>,
|
// cx: &mut ViewContext<Workspace>,
|
||||||
// ) -> Task<Result<()>> {
|
// ) -> Task<Result<()>> {
|
||||||
// self.navigate_history(pane, NavigationMode::GoingForward, cx)
|
// self.navigate_history(pane, NavigationMode::GoingForward, cx)
|
||||||
|
@ -1592,11 +1555,11 @@ impl Workspace {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn project_path_for_path(
|
fn project_path_for_path(
|
||||||
project: Handle<Project>,
|
project: Model<Project>,
|
||||||
abs_path: &Path,
|
abs_path: &Path,
|
||||||
visible: bool,
|
visible: bool,
|
||||||
cx: &mut AppContext,
|
cx: &mut AppContext,
|
||||||
) -> Task<Result<(Handle<Worktree>, ProjectPath)>> {
|
) -> Task<Result<(Model<Worktree>, ProjectPath)>> {
|
||||||
let entry = project.update(cx, |project, cx| {
|
let entry = project.update(cx, |project, cx| {
|
||||||
project.find_or_create_local_worktree(abs_path, visible, cx)
|
project.find_or_create_local_worktree(abs_path, visible, cx)
|
||||||
});
|
});
|
||||||
|
@ -1957,21 +1920,21 @@ impl Workspace {
|
||||||
// cx.notify();
|
// cx.notify();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// fn add_pane(&mut self, cx: &mut ViewContext<Self>) -> View<Pane> {
|
fn add_pane(&mut self, cx: &mut ViewContext<Self>) -> View<Pane> {
|
||||||
// let pane = cx.add_view(|cx| {
|
let pane = cx.build_view(|cx| {
|
||||||
// Pane::new(
|
Pane::new(
|
||||||
// self.weak_handle(),
|
self.weak_handle(),
|
||||||
// self.project.clone(),
|
self.project.clone(),
|
||||||
// self.pane_history_timestamp.clone(),
|
self.pane_history_timestamp.clone(),
|
||||||
// cx,
|
cx,
|
||||||
// )
|
)
|
||||||
// });
|
});
|
||||||
// cx.subscribe(&pane, Self::handle_pane_event).detach();
|
cx.subscribe(&pane, Self::handle_pane_event).detach();
|
||||||
// self.panes.push(pane.clone());
|
self.panes.push(pane.clone());
|
||||||
// cx.focus(&pane);
|
cx.focus(&pane);
|
||||||
// cx.emit(Event::PaneAdded(pane.clone()));
|
cx.emit(Event::PaneAdded(pane.clone()));
|
||||||
// pane
|
pane
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn add_item_to_center(
|
// pub fn add_item_to_center(
|
||||||
// &mut self,
|
// &mut self,
|
||||||
|
@ -2397,9 +2360,9 @@ impl Workspace {
|
||||||
|
|
||||||
// pub fn split_pane_with_item(
|
// pub fn split_pane_with_item(
|
||||||
// &mut self,
|
// &mut self,
|
||||||
// pane_to_split: WeakViewHandle<Pane>,
|
// pane_to_split: WeakView<Pane>,
|
||||||
// split_direction: SplitDirection,
|
// split_direction: SplitDirection,
|
||||||
// from: WeakViewHandle<Pane>,
|
// from: WeakView<Pane>,
|
||||||
// item_id_to_move: usize,
|
// item_id_to_move: usize,
|
||||||
// cx: &mut ViewContext<Self>,
|
// cx: &mut ViewContext<Self>,
|
||||||
// ) {
|
// ) {
|
||||||
|
@ -2420,7 +2383,7 @@ impl Workspace {
|
||||||
|
|
||||||
// pub fn split_pane_with_project_entry(
|
// pub fn split_pane_with_project_entry(
|
||||||
// &mut self,
|
// &mut self,
|
||||||
// pane_to_split: WeakViewHandle<Pane>,
|
// pane_to_split: WeakView<Pane>,
|
||||||
// split_direction: SplitDirection,
|
// split_direction: SplitDirection,
|
||||||
// project_entry: ProjectEntryId,
|
// project_entry: ProjectEntryId,
|
||||||
// cx: &mut ViewContext<Self>,
|
// cx: &mut ViewContext<Self>,
|
||||||
|
@ -2899,7 +2862,7 @@ impl Workspace {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// async fn process_leader_update(
|
// async fn process_leader_update(
|
||||||
// this: &WeakViewHandle<Self>,
|
// this: &WeakView<Self>,
|
||||||
// leader_id: PeerId,
|
// leader_id: PeerId,
|
||||||
// update: proto::UpdateFollowers,
|
// update: proto::UpdateFollowers,
|
||||||
// cx: &mut AsyncAppContext,
|
// cx: &mut AsyncAppContext,
|
||||||
|
@ -2958,7 +2921,7 @@ impl Workspace {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// async fn add_views_from_leader(
|
// async fn add_views_from_leader(
|
||||||
// this: WeakViewHandle<Self>,
|
// this: WeakView<Self>,
|
||||||
// leader_id: PeerId,
|
// leader_id: PeerId,
|
||||||
// panes: Vec<View<Pane>>,
|
// panes: Vec<View<Pane>>,
|
||||||
// views: Vec<proto::View>,
|
// views: Vec<proto::View>,
|
||||||
|
@ -3045,25 +3008,25 @@ impl Workspace {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// fn update_followers(
|
fn update_followers(
|
||||||
// &self,
|
&self,
|
||||||
// project_only: bool,
|
project_only: bool,
|
||||||
// update: proto::update_followers::Variant,
|
update: proto::update_followers::Variant,
|
||||||
// cx: &AppContext,
|
cx: &AppContext,
|
||||||
// ) -> Option<()> {
|
) -> Option<()> {
|
||||||
// let project_id = if project_only {
|
let project_id = if project_only {
|
||||||
// self.project.read(cx).remote_id()
|
self.project.read(cx).remote_id()
|
||||||
// } else {
|
} else {
|
||||||
// None
|
None
|
||||||
// };
|
};
|
||||||
// self.app_state().workspace_store.read_with(cx, |store, cx| {
|
self.app_state().workspace_store.read_with(cx, |store, cx| {
|
||||||
// store.update_followers(project_id, update, cx)
|
store.update_followers(project_id, update, cx)
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn leader_for_pane(&self, pane: &View<Pane>) -> Option<PeerId> {
|
pub fn leader_for_pane(&self, pane: &View<Pane>) -> Option<PeerId> {
|
||||||
// self.follower_states.get(pane).map(|state| state.leader_id)
|
self.follower_states.get(pane).map(|state| state.leader_id)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn leader_updated(&mut self, leader_id: PeerId, cx: &mut ViewContext<Self>) -> Option<()> {
|
// fn leader_updated(&mut self, leader_id: PeerId, cx: &mut ViewContext<Self>) -> Option<()> {
|
||||||
// cx.notify();
|
// cx.notify();
|
||||||
|
@ -3380,7 +3343,7 @@ impl Workspace {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub(crate) fn load_workspace(
|
// pub(crate) fn load_workspace(
|
||||||
// workspace: WeakViewHandle<Workspace>,
|
// workspace: WeakView<Workspace>,
|
||||||
// serialized_workspace: SerializedWorkspace,
|
// serialized_workspace: SerializedWorkspace,
|
||||||
// paths_to_open: Vec<Option<ProjectPath>>,
|
// paths_to_open: Vec<Option<ProjectPath>>,
|
||||||
// cx: &mut AppContext,
|
// cx: &mut AppContext,
|
||||||
|
@ -3570,7 +3533,7 @@ impl Workspace {
|
||||||
|
|
||||||
// async fn open_items(
|
// async fn open_items(
|
||||||
// serialized_workspace: Option<SerializedWorkspace>,
|
// serialized_workspace: Option<SerializedWorkspace>,
|
||||||
// workspace: &WeakViewHandle<Workspace>,
|
// workspace: &WeakView<Workspace>,
|
||||||
// mut project_paths_to_open: Vec<(PathBuf, Option<ProjectPath>)>,
|
// mut project_paths_to_open: Vec<(PathBuf, Option<ProjectPath>)>,
|
||||||
// app_state: Arc<AppState>,
|
// app_state: Arc<AppState>,
|
||||||
// mut cx: AsyncAppContext,
|
// mut cx: AsyncAppContext,
|
||||||
|
@ -3660,7 +3623,7 @@ impl Workspace {
|
||||||
// Ok(opened_items)
|
// Ok(opened_items)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// fn notify_of_new_dock(workspace: &WeakViewHandle<Workspace>, cx: &mut AsyncAppContext) {
|
// fn notify_of_new_dock(workspace: &WeakView<Workspace>, cx: &mut AsyncAppContext) {
|
||||||
// const NEW_PANEL_BLOG_POST: &str = "https://zed.dev/blog/new-panel-system";
|
// const NEW_PANEL_BLOG_POST: &str = "https://zed.dev/blog/new-panel-system";
|
||||||
// const NEW_DOCK_HINT_KEY: &str = "show_new_dock_key";
|
// const NEW_DOCK_HINT_KEY: &str = "show_new_dock_key";
|
||||||
// const MESSAGE_ID: usize = 2;
|
// const MESSAGE_ID: usize = 2;
|
||||||
|
@ -3741,7 +3704,7 @@ impl Workspace {
|
||||||
// .ok();
|
// .ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn notify_if_database_failed(workspace: &WeakViewHandle<Workspace>, cx: &mut AsyncAppContext) {
|
// fn notify_if_database_failed(workspace: &WeakView<Workspace>, cx: &mut AsyncAppContext) {
|
||||||
// const REPORT_ISSUE_URL: &str ="https://github.com/zed-industries/community/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml";
|
// const REPORT_ISSUE_URL: &str ="https://github.com/zed-industries/community/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml";
|
||||||
|
|
||||||
// workspace
|
// workspace
|
||||||
|
@ -4054,23 +4017,23 @@ impl Workspace {
|
||||||
// type Event = ();
|
// type Event = ();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// impl ViewId {
|
impl ViewId {
|
||||||
// pub(crate) fn from_proto(message: proto::ViewId) -> Result<Self> {
|
pub(crate) fn from_proto(message: proto::ViewId) -> Result<Self> {
|
||||||
// Ok(Self {
|
Ok(Self {
|
||||||
// creator: message
|
creator: message
|
||||||
// .creator
|
.creator
|
||||||
// .ok_or_else(|| anyhow!("creator is missing"))?,
|
.ok_or_else(|| anyhow!("creator is missing"))?,
|
||||||
// id: message.id,
|
id: message.id,
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub(crate) fn to_proto(&self) -> proto::ViewId {
|
pub(crate) fn to_proto(&self) -> proto::ViewId {
|
||||||
// proto::ViewId {
|
proto::ViewId {
|
||||||
// creator: Some(self.creator),
|
creator: Some(self.creator),
|
||||||
// id: self.id,
|
id: self.id,
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub trait WorkspaceHandle {
|
// pub trait WorkspaceHandle {
|
||||||
// fn file_project_paths(&self, cx: &AppContext) -> Vec<ProjectPath>;
|
// fn file_project_paths(&self, cx: &AppContext) -> Vec<ProjectPath>;
|
||||||
|
@ -4099,7 +4062,7 @@ impl Workspace {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub struct WorkspaceCreated(pub WeakViewHandle<Workspace>);
|
// pub struct WorkspaceCreated(pub WeakView<Workspace>);
|
||||||
|
|
||||||
pub async fn activate_workspace_for_project(
|
pub async fn activate_workspace_for_project(
|
||||||
cx: &mut AsyncAppContext,
|
cx: &mut AsyncAppContext,
|
||||||
|
@ -4321,27 +4284,6 @@ pub async fn activate_workspace_for_project(
|
||||||
// None
|
// None
|
||||||
// }
|
// }
|
||||||
|
|
||||||
use client2::{
|
|
||||||
proto::{self, PeerId, ViewId},
|
|
||||||
Client, UserStore,
|
|
||||||
};
|
|
||||||
use collections::{HashMap, HashSet};
|
|
||||||
use gpui2::{
|
|
||||||
AnyHandle, AnyView, AppContext, AsyncAppContext, DisplayId, Handle, MainThread, Task, View,
|
|
||||||
ViewContext, WeakHandle, WeakView, WindowBounds, WindowHandle, WindowOptions,
|
|
||||||
};
|
|
||||||
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem};
|
|
||||||
use language2::LanguageRegistry;
|
|
||||||
use node_runtime::NodeRuntime;
|
|
||||||
use project2::{Project, ProjectEntryId, ProjectPath, Worktree};
|
|
||||||
use std::{
|
|
||||||
any::TypeId,
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
sync::Arc,
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
use util::ResultExt;
|
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub fn open_paths(
|
pub fn open_paths(
|
||||||
abs_paths: &[PathBuf],
|
abs_paths: &[PathBuf],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue