Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Merge branch 'zed2' into zed2-workspace

Mikayla3dadfb8ba809
diff --cc crates/gpui2/src/app.rs
index a4d574abcf8,1d2c17d3575..0aca9410a89
--- a/crates/gpui2/src/app.rs
+++ b/crates/gpui2/src/app.rs
@@@ -13,12 -13,11 +13,12 @@@ use smallvec::SmallVec
pub use test_context::*;
use crate::{
- current_platform, image_cache::ImageCache, Action, AnyBox, AnyView, AppMetadata, AssetSource,
- ClipboardItem, Context, DispatchPhase, DisplayId, Executor, FocusEvent, FocusHandle, FocusId,
- KeyBinding, Keymap, LayoutId, MainThread, MainThreadOnly, Pixels, Platform, Point, Render,
- SharedString, SubscriberSet, Subscription, SvgRenderer, Task, TextStyle, TextStyleRefinement,
- TextSystem, View, Window, WindowContext, WindowHandle, WindowId,
+ current_platform, image_cache::ImageCache, Action, AnyBox, AnyView, AnyWindowHandle,
+ AppMetadata, AssetSource, ClipboardItem, Context, DispatchPhase, DisplayId, Executor,
+ FocusEvent, FocusHandle, FocusId, KeyBinding, Keymap, LayoutId, MainThread, MainThreadOnly,
- Pixels, Platform, Point, SharedString, SubscriberSet, Subscription, SvgRenderer, Task,
++ Pixels, Platform, Point, Render, SharedString, SubscriberSet, Subscription, SvgRenderer, Task,
+ TextStyle, TextStyleRefinement, TextSystem, View, ViewContext, Window, WindowContext,
+ WindowHandle, WindowId,
};
use anyhow::{anyhow, Result};
use collections::{HashMap, HashSet, VecDeque};
@@@ -303,20 -295,6 +303,27 @@@ impl AppContext
})
}
+ pub fn update_window_root<V, R>(
+ &mut self,
+ handle: &WindowHandle<V>,
+ update: impl FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> R,
+ ) -> Result<R>
+ where
- V: 'static,
++ V: 'static + Send,
+ {
+ self.update_window(handle.any_handle, |cx| {
- let root_view = cx.window.root_view.as_ref().unwrap().downcast().unwrap();
++ let root_view = cx
++ .window
++ .root_view
++ .as_ref()
++ .unwrap()
++ .clone()
++ .downcast()
++ .unwrap();
+ root_view.update(cx, update)
+ })
+ }
+
pub(crate) fn push_effect(&mut self, effect: Effect) {
match &effect {
Effect::Notify { emitter } => {
@@@ -683,20 -654,6 +690,20 @@@
self.globals_by_type.insert(global_type, lease.global);
}
+ pub fn observe_release<E: 'static>(
+ &mut self,
- handle: &Handle<E>,
++ handle: &Model<E>,
+ mut on_release: impl FnMut(&mut E, &mut AppContext) + Send + 'static,
+ ) -> Subscription {
+ self.release_listeners.insert(
+ handle.entity_id,
+ Box::new(move |entity, cx| {
+ let entity = entity.downcast_mut().expect("invalid entity type");
+ on_release(entity, cx)
+ }),
+ )
+ }
+
pub(crate) fn push_text_style(&mut self, text_style: TextStyleRefinement) {
self.text_style_stack.push(text_style);
}
@@@ -855,20 -812,6 +862,27 @@@ impl MainThread<AppContext>
})
}
+ pub fn update_window_root<V, R>(
+ &mut self,
+ handle: &WindowHandle<V>,
+ update: impl FnOnce(&mut V, &mut MainThread<ViewContext<'_, '_, V>>) -> R,
+ ) -> Result<R>
+ where
- V: 'static,
++ V: 'static + Send,
+ {
+ self.update_window(handle.any_handle, |cx| {
- let root_view = cx.window.root_view.as_ref().unwrap().downcast().unwrap();
++ let root_view = cx
++ .window
++ .root_view
++ .as_ref()
++ .unwrap()
++ .clone()
++ .downcast()
++ .unwrap();
+ root_view.update(cx, update)
+ })
+ }
+
/// Opens a new window with the given option and the root view returned by the given function.
/// The function is invoked with a `WindowContext`, which can be used to interact with window-specific
/// functionality.
diff --cc crates/gpui2/src/app/async_context.rs
index 5998917e526,71417f2a5e8..a10f0eb9e7f
--- a/crates/gpui2/src/app/async_context.rs
+++ b/crates/gpui2/src/app/async_context.rs
@@@ -1,8 -1,8 +1,8 @@@
use crate::{
- AnyWindowHandle, AppContext, Component, Context, Executor, Handle, MainThread, ModelContext,
- Result, Task, View, ViewContext, VisualContext, WindowContext, WindowHandle,
+ AnyWindowHandle, AppContext, Context, Executor, MainThread, Model, ModelContext, Result, Task,
- WindowContext,
++ View, ViewContext, VisualContext, WindowContext, WindowHandle,
};
-use anyhow::anyhow;
+use anyhow::Context as _;
use derive_more::{Deref, DerefMut};
use parking_lot::Mutex;
use std::{future::Future, sync::Weak};
@@@ -24,17 -24,23 +24,17 @@@ impl Context for AsyncAppContext
where
T: 'static + Send,
{
- let app = self
- .app
- .upgrade()
- .ok_or_else(|| anyhow!("app was released"))?;
+ let app = self.app.upgrade().context("app was released")?;
let mut lock = app.lock(); // Need this to compile
- Ok(lock.entity(build_entity))
+ Ok(lock.build_model(build_model))
}
fn update_entity<T: 'static, R>(
&mut self,
- handle: &Handle<T>,
- update: impl FnOnce(&mut T, &mut Self::EntityContext<'_, T>) -> R,
+ handle: &Model<T>,
+ update: impl FnOnce(&mut T, &mut Self::ModelContext<'_, T>) -> R,
) -> Self::Result<R> {
- let app = self
- .app
- .upgrade()
- .ok_or_else(|| anyhow!("app was released"))?;
+ let app = self.app.upgrade().context("app was released")?;
let mut lock = app.lock(); // Need this to compile
Ok(lock.update_entity(handle, update))
}
@@@ -73,22 -88,12 +73,22 @@@ impl AsyncAppContext
handle: AnyWindowHandle,
update: impl FnOnce(&mut WindowContext) -> R,
) -> Result<R> {
- let app = self
- .app
- .upgrade()
- .ok_or_else(|| anyhow!("app was released"))?;
+ let app = self.app.upgrade().context("app was released")?;
let mut app_context = app.lock();
- app_context.update_window(handle.id, update)
+ app_context.update_window(handle, update)
+ }
+
+ pub fn update_window_root<V, R>(
+ &mut self,
+ handle: &WindowHandle<V>,
+ update: impl FnOnce(&mut V, &mut ViewContext<'_, '_, V>) -> R,
+ ) -> Result<R>
+ where
- V: 'static,
++ V: 'static + Send,
+ {
+ let app = self.app.upgrade().context("app was released")?;
+ let mut app_context = app.lock();
+ app_context.update_window_root(handle, update)
}
pub fn spawn<Fut, R>(&self, f: impl FnOnce(AsyncAppContext) -> Fut + Send + 'static) -> Task<R>
@@@ -258,32 -240,6 +258,30 @@@ impl Context for AsyncWindowContext
}
}
+impl VisualContext for AsyncWindowContext {
+ type ViewContext<'a, 'w, V> = ViewContext<'a, 'w, V>;
+
- fn build_view<E, V>(
++ fn build_view<V>(
+ &mut self,
- build_entity: impl FnOnce(&mut Self::ViewContext<'_, '_, V>) -> V,
- render: impl Fn(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + 'static,
++ build_view_state: impl FnOnce(&mut Self::ViewContext<'_, '_, V>) -> V,
+ ) -> Self::Result<View<V>>
+ where
- E: Component<V>,
+ V: 'static + Send,
+ {
+ self.app
- .update_window(self.window, |cx| cx.build_view(build_entity, render))
++ .update_window(self.window, |cx| cx.build_view(build_view_state))
+ }
+
+ fn update_view<V: 'static, R>(
+ &mut self,
+ view: &View<V>,
+ update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, '_, V>) -> R,
+ ) -> Self::Result<R> {
+ self.app
+ .update_window(self.window, |cx| cx.update_view(view, update))
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --cc crates/gpui2/src/view.rs
index a61fd104412,eef58193613..2b8794d8697
--- a/crates/gpui2/src/view.rs
+++ b/crates/gpui2/src/view.rs
@@@ -1,37 -1,22 +1,26 @@@
use crate::{
- AnyBox, AnyElement, AppContext, AvailableSpace, BorrowWindow, Bounds, Component, Element,
- ElementId, EntityHandle, EntityId, Flatten, Handle, LayoutId, Pixels, Size, ViewContext,
- VisualContext, WeakHandle, WindowContext,
+ AnyBox, AnyElement, AnyModel, AppContext, AvailableSpace, BorrowWindow, Bounds, Component,
- Element, ElementId, EntityId, LayoutId, Model, Pixels, Size, ViewContext, VisualContext,
- WeakModel, WindowContext,
++ Element, ElementId, EntityHandle, EntityId, Flatten, LayoutId, Model, Pixels, Size,
++ ViewContext, VisualContext, WeakModel, WindowContext,
};
use anyhow::{Context, Result};
- use parking_lot::Mutex;
-use std::{any::TypeId, marker::PhantomData, sync::Arc};
+use std::{
- any::Any,
++ any::{Any, TypeId},
+ marker::PhantomData,
- sync::{Arc, Weak},
++ sync::Arc,
+};
- pub struct View<V> {
- pub(crate) state: Handle<V>,
- render: Arc<Mutex<dyn Fn(&mut V, &mut ViewContext<V>) -> AnyElement<V> + Send + 'static>>,
+ pub trait Render: 'static + Sized {
+ type Element: Element<Self> + 'static + Send;
+
+ fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element;
}
- impl<V: 'static> View<V> {
- pub fn for_handle<E>(
- state: Handle<V>,
- render: impl Fn(&mut V, &mut ViewContext<'_, '_, V>) -> E + Send + 'static,
- ) -> View<V>
- where
- E: Component<V>,
- {
- View {
- state,
- render: Arc::new(Mutex::new(
- move |state: &mut V, cx: &mut ViewContext<'_, '_, V>| render(state, cx).render(),
- )),
- }
- }
+ pub struct View<V> {
+ pub(crate) model: Model<V>,
+ }
+ impl<V: Render> View<V> {
pub fn into_any(self) -> AnyView {
AnyView(Arc::new(self))
}
@@@ -117,48 -105,23 +109,46 @@@ wher
}
}
+impl<T: 'static> EntityHandle<T> for View<T> {
+ type Weak = WeakView<T>;
+
+ fn entity_id(&self) -> EntityId {
- self.state.entity_id
++ self.model.entity_id
+ }
+
+ fn downgrade(&self) -> Self::Weak {
+ self.downgrade()
+ }
+
+ fn upgrade_from(weak: &Self::Weak) -> Option<Self>
+ where
+ Self: Sized,
+ {
+ weak.upgrade()
+ }
+}
+
pub struct WeakView<V> {
- pub(crate) state: WeakHandle<V>,
- render: Weak<Mutex<dyn Fn(&mut V, &mut ViewContext<V>) -> AnyElement<V> + Send + 'static>>,
+ pub(crate) model: WeakModel<V>,
}
impl<V: 'static> WeakView<V> {
pub fn upgrade(&self) -> Option<View<V>> {
- let state = self.state.upgrade()?;
- let render = self.render.upgrade()?;
- Some(View { state, render })
+ let model = self.model.upgrade()?;
+ Some(View { model })
}
- pub fn update<R>(
+ pub fn update<C, R>(
&self,
- cx: &mut WindowContext,
- f: impl FnOnce(&mut V, &mut ViewContext<V>) -> R,
- ) -> Result<R> {
+ cx: &mut C,
+ f: impl FnOnce(&mut V, &mut C::ViewContext<'_, '_, V>) -> R,
+ ) -> Result<R>
+ where
+ C: VisualContext,
+ Result<C::Result<R>>: Flatten<R>,
+ {
let view = self.upgrade().context("error upgrading view")?;
- Ok(view.update(cx, f))
+ Ok(view.update(cx, f)).flatten()
}
}
@@@ -184,10 -146,10 +173,10 @@@ impl<V: Render, ParentV: 'static> Compo
}
}
- impl<V: 'static, ParentV: 'static> Element<ParentV> for EraseViewState<V, ParentV> {
+ impl<V: Render, ParentV: 'static> Element<ParentV> for EraseViewState<V, ParentV> {
type ElementState = AnyBox;
- fn id(&self) -> Option<crate::ElementId> {
+ fn id(&self) -> Option<ElementId> {
Element::id(&self.view)
}
@@@ -225,26 -189,36 +216,37 @@@ trait ViewObject: Send + Sync
fn initialize(&self, cx: &mut WindowContext) -> AnyBox;
fn layout(&self, element: &mut AnyBox, cx: &mut WindowContext) -> LayoutId;
fn paint(&self, bounds: Bounds<Pixels>, element: &mut AnyBox, cx: &mut WindowContext);
+ fn as_any(&self) -> &dyn Any;
}
- impl<V: 'static> ViewObject for View<V> {
+ impl<V> ViewObject for View<V>
+ where
+ V: Render,
+ {
+ fn entity_type(&self) -> TypeId {
+ TypeId::of::<V>()
+ }
+
fn entity_id(&self) -> EntityId {
- self.state.entity_id
+ self.model.entity_id
+ }
+
+ fn model(&self) -> AnyModel {
+ self.model.clone().into_any()
}
fn initialize(&self, cx: &mut WindowContext) -> AnyBox {
- cx.with_element_id(self.state.entity_id, |_global_id, cx| {
- cx.with_element_id(self.entity_id(), |_global_id, cx| {
++ cx.with_element_id(self.model.entity_id, |_global_id, cx| {
self.update(cx, |state, cx| {
- let mut any_element = Box::new((self.render.lock())(state, cx));
+ let mut any_element = Box::new(AnyElement::new(state.render(cx)));
any_element.initialize(state, cx);
- any_element as AnyBox
+ any_element
})
})
}
fn layout(&self, element: &mut AnyBox, cx: &mut WindowContext) -> LayoutId {
- cx.with_element_id(self.state.entity_id, |_global_id, cx| {
- cx.with_element_id(self.entity_id(), |_global_id, cx| {
++ cx.with_element_id(self.model.entity_id, |_global_id, cx| {
self.update(cx, |state, cx| {
let element = element.downcast_mut::<AnyElement<V>>().unwrap();
element.layout(state, cx)
@@@ -253,7 -227,7 +255,7 @@@
}
fn paint(&self, _: Bounds<Pixels>, element: &mut AnyBox, cx: &mut WindowContext) {
- cx.with_element_id(self.state.entity_id, |_global_id, cx| {
- cx.with_element_id(self.entity_id(), |_global_id, cx| {
++ cx.with_element_id(self.model.entity_id, |_global_id, cx| {
self.update(cx, |state, cx| {
let element = element.downcast_mut::<AnyElement<V>>().unwrap();
element.paint(state, cx);
diff --cc crates/gpui2/src/window.rs
index 0f2dcc7049b,d5e18e14392..2cf706eda4e
--- a/crates/gpui2/src/window.rs
+++ b/crates/gpui2/src/window.rs
@@@ -1,14 -1,14 +1,14 @@@
use crate::{
px, size, Action, AnyBox, AnyDrag, AnyView, AppContext, AsyncWindowContext, AvailableSpace,
Bounds, BoxShadow, Context, Corners, DevicePixels, DispatchContext, DisplayId, Edges, Effect,
- EntityHandle, EntityId, EventEmitter, ExternalPaths, FileDropEvent, FocusEvent, FontId,
- GlobalElementId, GlyphId, Handle, Hsla, ImageData, InputEvent, IsZero, KeyListener, KeyMatch,
- KeyMatcher, Keystroke, LayoutId, MainThread, MainThreadOnly, ModelContext, Modifiers,
- MonochromeSprite, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Path, Pixels,
- PlatformAtlas, PlatformWindow, Point, PolychromeSprite, Quad, Reference, RenderGlyphParams,
- RenderImageParams, RenderSvgParams, ScaledPixels, SceneBuilder, Shadow, SharedString, Size,
- Style, Subscription, TaffyLayoutEngine, Task, Underline, UnderlineStyle, View, VisualContext,
- WeakHandle, WeakView, WindowOptions, SUBPIXEL_VARIANTS,
- EntityId, EventEmitter, FileDropEvent, FocusEvent, FontId, GlobalElementId, GlyphId, Hsla,
- ImageData, InputEvent, IsZero, KeyListener, KeyMatch, KeyMatcher, Keystroke, LayoutId,
- MainThread, MainThreadOnly, Model, ModelContext, Modifiers, MonochromeSprite, MouseButton,
- MouseDownEvent, MouseMoveEvent, MouseUpEvent, Path, Pixels, PlatformAtlas, PlatformWindow,
- Point, PolychromeSprite, Quad, Reference, RenderGlyphParams, RenderImageParams,
++ EntityHandle, EntityId, EventEmitter, FileDropEvent, FocusEvent, FontId, GlobalElementId,
++ GlyphId, Hsla, ImageData, InputEvent, IsZero, KeyListener, KeyMatch, KeyMatcher, Keystroke,
++ LayoutId, MainThread, MainThreadOnly, Model, ModelContext, Modifiers, MonochromeSprite,
++ MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Path, Pixels, PlatformAtlas,
++ PlatformWindow, Point, PolychromeSprite, Quad, Reference, RenderGlyphParams, RenderImageParams,
+ RenderSvgParams, ScaledPixels, SceneBuilder, Shadow, SharedString, Size, Style, Subscription,
+ TaffyLayoutEngine, Task, Underline, UnderlineStyle, View, VisualContext, WeakModel, WeakView,
+ WindowOptions, SUBPIXEL_VARIANTS,
};
use anyhow::Result;
use collections::HashMap;
@@@ -1886,24 -1850,14 +1880,24 @@@ wher
}
}
+impl<'a, 'w, V: 'static> MainThread<ViewContext<'a, 'w, V>> {
+ fn platform_window(&self) -> &dyn PlatformWindow {
+ self.window.platform_window.borrow_on_main_thread().as_ref()
+ }
+
+ pub fn activate_window(&self) {
+ self.platform_window().activate();
+ }
+}
+
impl<'a, 'w, V> Context for ViewContext<'a, 'w, V> {
- type EntityContext<'b, U> = ModelContext<'b, U>;
+ type ModelContext<'b, U> = ModelContext<'b, U>;
type Result<U> = U;
- fn entity<T>(
+ fn build_model<T>(
&mut self,
- build_entity: impl FnOnce(&mut Self::EntityContext<'_, T>) -> T,
- ) -> Handle<T>
+ build_model: impl FnOnce(&mut Self::ModelContext<'_, T>) -> T,
+ ) -> Model<T>
where
T: 'static + Send,
{
diff --cc crates/workspace2/src/item.rs
index 90d08d6c4ad,90d08d6c4ad..eddc9200f9b
--- a/crates/workspace2/src/item.rs
+++ b/crates/workspace2/src/item.rs
@@@ -17,7 -17,7 +17,7 @@@ use theme2::Theme
// use gpui2::geometry::vector::Vector2F;
// use gpui2::AnyWindowHandle;
// use gpui2::{
--// fonts::HighlightStyle, AnyElement, AnyViewHandle, AppContext, Handle, Task, View,
++// fonts::HighlightStyle, AnyElement, AnyViewHandle, AppContext, Model, Task, View,
// ViewContext, View, WeakViewHandle, WindowContext,
// };
// use project2::{Project, ProjectEntryId, ProjectPath};
@@@ -135,14 -135,14 +135,14 @@@ pub trait Item: EventEmitter + Sized
// }
// fn save(
// &mut self,
-- // _project: Handle<Project>,
++ // _project: Model<Project>,
// _cx: &mut ViewContext<Self>,
// ) -> Task<Result<()>> {
// unimplemented!("save() must be implemented if can_save() returns true")
// }
// fn save_as(
// &mut self,
-- // _project: Handle<Project>,
++ // _project: Model<Project>,
// _abs_path: PathBuf,
// _cx: &mut ViewContext<Self>,
// ) -> Task<Result<()>> {
@@@ -150,7 -150,7 +150,7 @@@
// }
// fn reload(
// &mut self,
-- // _project: Handle<Project>,
++ // _project: Model<Project>,
// _cx: &mut ViewContext<Self>,
// ) -> Task<Result<()>> {
// unimplemented!("reload() must be implemented if can_save() returns true")
@@@ -197,7 -197,7 +197,7 @@@
// }
// fn deserialize(
-- // _project: Handle<Project>,
++ // _project: Model<Project>,
// _workspace: WeakViewHandle<Workspace>,
// _workspace_id: WorkspaceId,
// _item_id: ItemId,
@@@ -229,8 -229,8 +229,8 @@@ use std::
};
use gpui2::{
-- AnyElement, AnyWindowHandle, AppContext, EventEmitter, Handle, HighlightStyle, Pixels, Point,
-- SharedString, Task, View, ViewContext, VisualContext, WindowContext,
++ AnyElement, AnyWindowHandle, AppContext, EventEmitter, HighlightStyle, Model, Pixels, Point,
++ SharedString, Task, View, ViewContext, WindowContext,
};
use project2::{Project, ProjectEntryId, ProjectPath};
use smallvec::SmallVec;
@@@ -279,14 -279,14 +279,14 @@@ pub trait ItemHandle: 'static + Send
fn is_dirty(&self, cx: &AppContext) -> bool;
fn has_conflict(&self, cx: &AppContext) -> bool;
fn can_save(&self, cx: &AppContext) -> bool;
-- fn save(&self, project: Handle<Project>, cx: &mut WindowContext) -> Task<Result<()>>;
++ fn save(&self, project: Model<Project>, cx: &mut WindowContext) -> Task<Result<()>>;
fn save_as(
&self,
-- project: Handle<Project>,
++ project: Model<Project>,
abs_path: PathBuf,
cx: &mut WindowContext,
) -> Task<Result<()>>;
-- fn reload(&self, project: Handle<Project>, cx: &mut WindowContext) -> Task<Result<()>>;
++ fn reload(&self, project: Model<Project>, cx: &mut WindowContext) -> Task<Result<()>>;
// fn act_as_type<'a>(&'a self, type_id: TypeId, cx: &'a AppContext) -> Option<&'a AnyViewHandle>; todo!()
fn to_followable_item_handle(&self, cx: &AppContext) -> Option<Box<dyn FollowableItemHandle>>;
fn on_release(
@@@ -587,20 -587,20 +587,20 @@@ impl<T: Item> ItemHandle for View<T>
self.read(cx).can_save(cx)
}
-- fn save(&self, project: Handle<Project>, cx: &mut WindowContext) -> Task<Result<()>> {
++ fn save(&self, project: Model<Project>, cx: &mut WindowContext) -> Task<Result<()>> {
self.update(cx, |item, cx| item.save(project, cx))
}
fn save_as(
&self,
-- project: Handle<Project>,
++ project: Model<Project>,
abs_path: PathBuf,
cx: &mut WindowContext,
) -> Task<anyhow::Result<()>> {
self.update(cx, |item, cx| item.save_as(project, abs_path, cx))
}
-- fn reload(&self, project: Handle<Project>, cx: &mut WindowContext) -> Task<Result<()>> {
++ fn reload(&self, project: Model<Project>, cx: &mut WindowContext) -> Task<Result<()>> {
self.update(cx, |item, cx| item.reload(project, cx))
}
@@@ -688,8 -688,8 +688,8 @@@ pub trait ProjectItem: Item
type Item: project2::Item;
fn for_project_item(
-- project: Handle<Project>,
-- item: Handle<Self::Item>,
++ project: Model<Project>,
++ item: Model<Self::Item>,
cx: &mut ViewContext<Self>,
) -> Self
where
@@@ -714,7 -714,7 +714,7 @@@ pub trait FollowableItem: Item
) -> bool;
fn apply_update_proto(
&mut self,
-- project: &Handle<Project>,
++ project: &Model<Project>,
message: proto::update_view::Variant,
cx: &mut ViewContext<Self>,
) -> Task<Result<()>>;
@@@ -736,7 -736,7 +736,7 @@@ pub trait FollowableItemHandle: ItemHan
) -> bool;
fn apply_update_proto(
&self,
-- project: &Handle<Project>,
++ project: &Model<Project>,
message: proto::update_view::Variant,
cx: &mut WindowContext,
) -> Task<Result<()>>;
@@@ -777,7 -777,7 +777,7 @@@
// fn apply_update_proto(
// &self,
--// project: &Handle<Project>,
++// project: &Model<Project>,
// message: proto::update_view::Variant,
// cx: &mut WindowContext,
// ) -> Task<Result<()>> {
@@@ -802,7 -802,7 +802,7 @@@
// use super::{Item, ItemEvent};
// use crate::{ItemId, ItemNavHistory, Pane, Workspace, WorkspaceId};
// use gpui2::{
--// elements::Empty, AnyElement, AppContext, Element, Entity, Handle, Task, View,
++// elements::Empty, AnyElement, AppContext, Element, Entity, Model, Task, View,
// ViewContext, View, WeakViewHandle,
// };
// use project2::{Project, ProjectEntryId, ProjectPath, WorktreeId};
@@@ -824,7 -824,7 +824,7 @@@
// pub is_dirty: bool,
// pub is_singleton: bool,
// pub has_conflict: bool,
--// pub project_items: Vec<Handle<TestProjectItem>>,
++// pub project_items: Vec<Model<TestProjectItem>>,
// pub nav_history: Option<ItemNavHistory>,
// pub tab_descriptions: Option<Vec<&'static str>>,
// pub tab_detail: Cell<Option<usize>>,
@@@ -869,7 -869,7 +869,7 @@@
// }
// impl TestProjectItem {
--// pub fn new(id: u64, path: &str, cx: &mut AppContext) -> Handle<Self> {
++// pub fn new(id: u64, path: &str, cx: &mut AppContext) -> Model<Self> {
// let entry_id = Some(ProjectEntryId::from_proto(id));
// let project_path = Some(ProjectPath {
// worktree_id: WorktreeId::from_usize(0),
@@@ -881,7 -881,7 +881,7 @@@
// })
// }
--// pub fn new_untitled(cx: &mut AppContext) -> Handle<Self> {
++// pub fn new_untitled(cx: &mut AppContext) -> Model<Self> {
// cx.add_model(|_| Self {
// project_path: None,
// entry_id: None,
@@@ -934,7 -934,7 +934,7 @@@
// self
// }
--// pub fn with_project_items(mut self, items: &[Handle<TestProjectItem>]) -> Self {
++// pub fn with_project_items(mut self, items: &[Model<TestProjectItem>]) -> Self {
// self.project_items.clear();
// self.project_items.extend(items.iter().cloned());
// self
@@@ -1045,7 -1045,7 +1045,7 @@@
// fn save(
// &mut self,
--// _: Handle<Project>,
++// _: Model<Project>,
// _: &mut ViewContext<Self>,
// ) -> Task<anyhow::Result<()>> {
// self.save_count += 1;
@@@ -1055,7 -1055,7 +1055,7 @@@
// fn save_as(
// &mut self,
--// _: Handle<Project>,
++// _: Model<Project>,
// _: std::path::PathBuf,
// _: &mut ViewContext<Self>,
// ) -> Task<anyhow::Result<()>> {
@@@ -1066,7 -1066,7 +1066,7 @@@
// fn reload(
// &mut self,
--// _: Handle<Project>,
++// _: Model<Project>,
// _: &mut ViewContext<Self>,
// ) -> Task<anyhow::Result<()>> {
// self.reload_count += 1;
@@@ -1083,7 -1083,7 +1083,7 @@@
// }
// fn deserialize(
--// _project: Handle<Project>,
++// _project: Model<Project>,
// _workspace: WeakViewHandle<Workspace>,
// workspace_id: WorkspaceId,
// _item_id: ItemId,
diff --cc crates/zed2/src/zed2.rs
index 9782c6dd05b,45a9276b2ba..bf4133214f7
--- a/crates/zed2/src/zed2.rs
+++ b/crates/zed2/src/zed2.rs
@@@ -4,8 -4,7 +4,8 @@@ mod open_listener
pub use assets::*;
use client2::{Client, UserStore};
+use collections::HashMap;
- use gpui2::{AsyncAppContext, Handle, Point};
+ use gpui2::{AsyncAppContext, Model};
pub use only_instance::*;
pub use open_listener::*;