diff --git a/crates/gpui2/src/app.rs b/crates/gpui2/src/app.rs index bbc6bfa567ca0fad67d8d1e2634bb6c115ac53dc..66c10f901df2e13a09101d06184ab96c7495d6d7 100644 --- a/crates/gpui2/src/app.rs +++ b/crates/gpui2/src/app.rs @@ -18,8 +18,8 @@ use crate::{ AppMetadata, AssetSource, ClipboardItem, Context, DispatchPhase, DisplayId, Entity, Executor, FocusEvent, FocusHandle, FocusId, KeyBinding, Keymap, LayoutId, MainThread, MainThreadOnly, Pixels, Platform, PlatformDisplay, Point, Render, SharedString, SubscriberSet, Subscription, - SvgRenderer, Task, TextStyle, TextStyleRefinement, TextSystem, View, ViewContext, Window, - WindowContext, WindowHandle, WindowId, + SvgRenderer, Task, TextStyle, TextStyleRefinement, TextSystem, View, Window, WindowContext, + WindowHandle, WindowId, }; use anyhow::{anyhow, Result}; use collections::{HashMap, HashSet, VecDeque}; @@ -267,27 +267,6 @@ impl AppContext { .collect() } - pub fn update_window_root( - &mut self, - handle: &WindowHandle, - update: impl FnOnce(&mut V, &mut ViewContext<'_, V>) -> R, - ) -> Result - where - V: 'static + Send, - { - self.update_window(handle.any_handle, |cx| { - 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 } => { @@ -354,7 +333,7 @@ impl AppContext { .collect::>(); for dirty_window_handle in dirty_window_ids { - self.update_window(dirty_window_handle, |cx| cx.draw()) + self.update_window(dirty_window_handle, |_, cx| cx.draw()) .unwrap(); } } @@ -384,7 +363,7 @@ impl AppContext { /// a window blur handler to restore focus to some logical element. fn release_dropped_focus_handles(&mut self) { for window_handle in self.windows() { - self.update_window(window_handle, |cx| { + self.update_window(window_handle, |_, cx| { let mut blur_window = false; let focus = cx.window.focus; cx.window.focus_handles.write().retain(|handle_id, count| { @@ -424,7 +403,7 @@ impl AppContext { window_handle: AnyWindowHandle, focused: Option, ) { - self.update_window(window_handle, |cx| { + self.update_window(window_handle, |_, cx| { if cx.window.focus == focused { let mut listeners = mem::take(&mut cx.window.focus_listeners); let focused = @@ -764,7 +743,7 @@ impl Context for AppContext { fn update_window(&mut self, handle: AnyWindowHandle, update: F) -> Result where - F: FnOnce(&mut Self::WindowContext<'_>) -> T, + F: FnOnce(AnyView, &mut Self::WindowContext<'_>) -> T, { self.update(|cx| { let mut window = cx @@ -774,8 +753,8 @@ impl Context for AppContext { .take() .unwrap(); - let result = update(&mut WindowContext::new(cx, &mut window)); - + let root_view = window.root_view.clone().unwrap(); + let result = update(root_view, &mut WindowContext::new(cx, &mut window)); cx.windows .get_mut(handle.id) .ok_or_else(|| anyhow!("window not found"))? @@ -854,39 +833,6 @@ impl MainThread { }) } - pub fn update_window( - &mut self, - handle: AnyWindowHandle, - update: impl FnOnce(&mut MainThread) -> R, - ) -> Result { - self.0.update_window(handle, |cx| { - update(unsafe { - std::mem::transmute::<&mut WindowContext, &mut MainThread>(cx) - }) - }) - } - - pub fn update_window_root( - &mut self, - handle: &WindowHandle, - update: impl FnOnce(&mut V, &mut MainThread>) -> R, - ) -> Result - where - V: 'static + Send, - { - self.update_window(handle.any_handle, |cx| { - 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 --git a/crates/gpui2/src/app/async_context.rs b/crates/gpui2/src/app/async_context.rs index 06da000ca685159b079374acb570c6da98cab990..d2820aa1fc17c7e5e0f54099dcd51e762f2dd240 100644 --- a/crates/gpui2/src/app/async_context.rs +++ b/crates/gpui2/src/app/async_context.rs @@ -42,7 +42,7 @@ impl Context for AsyncAppContext { fn update_window(&mut self, window: AnyWindowHandle, f: F) -> Result where - F: FnOnce(&mut Self::WindowContext<'_>) -> T, + F: FnOnce(AnyView, &mut Self::WindowContext<'_>) -> T, { let app = self.app.upgrade().context("app was released")?; let mut lock = app.lock(); // Need this to compile @@ -68,29 +68,6 @@ impl AsyncAppContext { Ok(f(&mut *lock)) } - pub fn update_window( - &self, - window: AnyWindowHandle, - update: impl FnOnce(&mut WindowContext) -> R, - ) -> Result { - let app = self.app.upgrade().context("app was released")?; - let mut app_context = app.lock(); - app_context.update_window(window, update) - } - - pub fn update_window_root( - &mut self, - handle: &WindowHandle, - update: impl FnOnce(&mut V, &mut ViewContext<'_, V>) -> R, - ) -> Result - where - 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(&self, f: impl FnOnce(AsyncAppContext) -> Fut + Send + 'static) -> Task where Fut: Future + Send + 'static, @@ -191,22 +168,25 @@ impl AsyncWindowContext { Self { app, window } } - pub fn update(&self, update: impl FnOnce(&mut WindowContext) -> R) -> Result { + pub fn update( + &mut self, + update: impl FnOnce(AnyView, &mut WindowContext) -> R, + ) -> Result { self.app.update_window(self.window, update) } pub fn on_next_frame(&mut self, f: impl FnOnce(&mut WindowContext) + Send + 'static) { self.app - .update_window(self.window, |cx| cx.on_next_frame(f)) + .update_window(self.window, |_root, cx| cx.on_next_frame(f)) .ok(); } pub fn read_global( - &self, + &mut self, read: impl FnOnce(&G, &WindowContext) -> R, ) -> Result { self.app - .update_window(self.window, |cx| read(cx.global(), cx)) + .update_window(self.window, |_, cx| read(cx.global(), cx)) } pub fn update_global( @@ -217,7 +197,7 @@ impl AsyncWindowContext { G: 'static, { self.app - .update_window(self.window, |cx| cx.update_global(update)) + .update_window(self.window, |_, cx| cx.update_global(update)) } pub fn spawn( @@ -245,13 +225,13 @@ impl AsyncWindowContext { } pub fn run_on_main( - &self, + &mut self, f: impl FnOnce(&mut MainThread) -> R + Send + 'static, ) -> Task> where R: Send + 'static, { - self.update(|cx| cx.run_on_main(f)) + self.update(|_, cx| cx.run_on_main(f)) .unwrap_or_else(|error| Task::ready(Err(error))) } } @@ -270,7 +250,7 @@ impl Context for AsyncWindowContext { T: 'static + Send, { self.app - .update_window(self.window, |cx| cx.build_model(build_model)) + .update_window(self.window, |_, cx| cx.build_model(build_model)) } fn update_model( @@ -279,12 +259,12 @@ impl Context for AsyncWindowContext { update: impl FnOnce(&mut T, &mut Self::ModelContext<'_, T>) -> R, ) -> Result { self.app - .update_window(self.window, |cx| cx.update_model(handle, update)) + .update_window(self.window, |_, cx| cx.update_model(handle, update)) } fn update_window(&mut self, window: AnyWindowHandle, update: F) -> Result where - F: FnOnce(&mut Self::WindowContext<'_>) -> T, + F: FnOnce(AnyView, &mut Self::WindowContext<'_>) -> T, { self.app.update_window(window, update) } @@ -293,10 +273,6 @@ impl Context for AsyncWindowContext { impl VisualContext for AsyncWindowContext { type ViewContext<'a, V: 'static> = ViewContext<'a, V>; - fn root_view(&self) -> Result { - self.app.update_window(self.window, |cx| cx.root_view()) - } - fn build_view( &mut self, build_view_state: impl FnOnce(&mut Self::ViewContext<'_, V>) -> V, @@ -305,7 +281,7 @@ impl VisualContext for AsyncWindowContext { V: 'static + Send, { self.app - .update_window(self.window, |cx| cx.build_view(build_view_state)) + .update_window(self.window, |_, cx| cx.build_view(build_view_state)) } fn update_view( @@ -314,7 +290,7 @@ impl VisualContext for AsyncWindowContext { update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, V>) -> R, ) -> Self::Result { self.app - .update_window(self.window, |cx| cx.update_view(view, update)) + .update_window(self.window, |_, cx| cx.update_view(view, update)) } fn replace_root_view( @@ -325,7 +301,7 @@ impl VisualContext for AsyncWindowContext { V: 'static + Send + Render, { self.app - .update_window(self.window, |cx| cx.replace_root_view(build_view)) + .update_window(self.window, |_, cx| cx.replace_root_view(build_view)) } } diff --git a/crates/gpui2/src/app/model_context.rs b/crates/gpui2/src/app/model_context.rs index c8b3eacdbc3054151552b209583cd31ccd0c7d8c..bc36d6854029451778373a963306ec5c674b62ba 100644 --- a/crates/gpui2/src/app/model_context.rs +++ b/crates/gpui2/src/app/model_context.rs @@ -1,6 +1,6 @@ use crate::{ - AnyWindowHandle, AppContext, AsyncAppContext, Context, Effect, Entity, EntityId, EventEmitter, - MainThread, Model, Subscription, Task, WeakModel, WindowContext, + AnyView, AnyWindowHandle, AppContext, AsyncAppContext, Context, Effect, Entity, EntityId, + EventEmitter, MainThread, Model, Subscription, Task, WeakModel, WindowContext, }; use anyhow::Result; use derive_more::{Deref, DerefMut}; @@ -253,7 +253,7 @@ impl<'a, T> Context for ModelContext<'a, T> { fn update_window(&mut self, window: AnyWindowHandle, update: F) -> Result where - F: FnOnce(&mut Self::WindowContext<'_>) -> R, + F: FnOnce(AnyView, &mut Self::WindowContext<'_>) -> R, { self.app.update_window(window, update) } diff --git a/crates/gpui2/src/app/test_context.rs b/crates/gpui2/src/app/test_context.rs index c53aefe5659da6bb4ab0dbe8ec7ca0626b7c7ca2..90ea7dd91dfc3f2e6599583c8fd28fa33eb4aaa3 100644 --- a/crates/gpui2/src/app/test_context.rs +++ b/crates/gpui2/src/app/test_context.rs @@ -1,5 +1,5 @@ use crate::{ - AnyWindowHandle, AppContext, AsyncAppContext, Context, Executor, MainThread, Model, + AnyView, AnyWindowHandle, AppContext, AsyncAppContext, Context, Executor, MainThread, Model, ModelContext, Result, Task, TestDispatcher, TestPlatform, WindowContext, }; use parking_lot::Mutex; @@ -38,7 +38,7 @@ impl Context for TestAppContext { fn update_window(&mut self, window: AnyWindowHandle, f: F) -> Result where - F: FnOnce(&mut Self::WindowContext<'_>) -> T, + F: FnOnce(AnyView, &mut Self::WindowContext<'_>) -> T, { let mut lock = self.app.lock(); lock.update_window(window, f) @@ -76,15 +76,6 @@ impl TestAppContext { f(&mut *lock) } - pub fn update_window( - &self, - handle: AnyWindowHandle, - update: impl FnOnce(&mut WindowContext) -> R, - ) -> R { - let mut app = self.app.lock(); - app.update_window(handle, update).unwrap() - } - pub fn spawn(&self, f: impl FnOnce(AsyncAppContext) -> Fut + Send + 'static) -> Task where Fut: Future + Send + 'static, diff --git a/crates/gpui2/src/gpui2.rs b/crates/gpui2/src/gpui2.rs index 74cfed1959062178a0d006de6284ae2e950fc940..58e1a7fc54034ae9ba3741240b583a259858e881 100644 --- a/crates/gpui2/src/gpui2.rs +++ b/crates/gpui2/src/gpui2.rs @@ -98,7 +98,7 @@ pub trait Context { fn update_window(&mut self, window: AnyWindowHandle, f: F) -> Result where - F: FnOnce(&mut Self::WindowContext<'_>) -> T; + F: FnOnce(AnyView, &mut Self::WindowContext<'_>) -> T; } pub trait VisualContext: Context { @@ -199,15 +199,15 @@ impl Context for MainThread { fn update_window(&mut self, window: AnyWindowHandle, update: F) -> Result where - F: FnOnce(&mut Self::WindowContext<'_>) -> T, + F: FnOnce(AnyView, &mut Self::WindowContext<'_>) -> T, { - self.0.update_window(window, |cx| { + self.0.update_window(window, |root, cx| { let cx = unsafe { mem::transmute::<&mut C::WindowContext<'_>, &mut MainThread>>( cx, ) }; - update(cx) + update(root, cx) }) } } @@ -215,10 +215,6 @@ impl Context for MainThread { impl VisualContext for MainThread { type ViewContext<'a, V: 'static> = MainThread>; - fn root_view(&self) -> AnyView { - self.0.root_view() - } - fn build_view( &mut self, build_view_state: impl FnOnce(&mut Self::ViewContext<'_, V>) -> V, diff --git a/crates/gpui2/src/window.rs b/crates/gpui2/src/window.rs index e6046e14cfbb20714513b8949291dd698a95ad40..36452bbf034e0517ccb72666b6cb164ab4f2966a 100644 --- a/crates/gpui2/src/window.rs +++ b/crates/gpui2/src/window.rs @@ -1,16 +1,16 @@ use crate::{ px, size, Action, AnyBox, AnyDrag, AnyView, AppContext, AsyncWindowContext, AvailableSpace, Bounds, BoxShadow, Context, Corners, DevicePixels, DispatchContext, DisplayId, Edges, Effect, - Entity, EntityId, EventEmitter, FileDropEvent, Flatten, 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, Render, RenderGlyphParams, RenderImageParams, - RenderSvgParams, ScaledPixels, SceneBuilder, Shadow, SharedString, Size, Style, Subscription, - TaffyLayoutEngine, Task, Underline, UnderlineStyle, View, VisualContext, WeakView, - WindowOptions, SUBPIXEL_VARIANTS, + Entity, 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, Render, RenderGlyphParams, RenderImageParams, RenderSvgParams, + ScaledPixels, SceneBuilder, Shadow, SharedString, Size, Style, Subscription, TaffyLayoutEngine, + Task, Underline, UnderlineStyle, View, VisualContext, WeakView, WindowOptions, + SUBPIXEL_VARIANTS, }; -use anyhow::Result; +use anyhow::{anyhow, Result}; use collections::HashMap; use derive_more::{Deref, DerefMut}; use parking_lot::RwLock; @@ -204,9 +204,9 @@ impl Window { let content_size = platform_window.content_size(); let scale_factor = platform_window.scale_factor(); platform_window.on_resize(Box::new({ - let cx = cx.to_async(); + let mut cx = cx.to_async(); move |content_size, scale_factor| { - cx.update_window(handle, |cx| { + cx.update_window(handle, |_, cx| { cx.window.scale_factor = scale_factor; cx.window.scene_builder = SceneBuilder::new(); cx.window.content_size = content_size; @@ -223,9 +223,9 @@ impl Window { })); platform_window.on_input({ - let cx = cx.to_async(); + let mut cx = cx.to_async(); Box::new(move |event| { - cx.update_window(handle, |cx| cx.dispatch_event(event)) + cx.update_window(handle, |_, cx| cx.dispatch_event(event)) .log_err() .unwrap_or(true) }) @@ -372,7 +372,7 @@ impl<'a> WindowContext<'a> { pub fn defer(&mut self, f: impl FnOnce(&mut WindowContext) + 'static + Send) { let window = self.window.handle; self.app.defer(move |cx| { - cx.update_window(window, f).ok(); + cx.update_window(window, |_, cx| f(cx)).ok(); }); } @@ -391,7 +391,7 @@ impl<'a> WindowContext<'a> { self.app.event_listeners.insert( entity_id, Box::new(move |event, cx| { - cx.update_window(window_handle, |cx| { + cx.update_window(window_handle, |_, cx| { if let Some(handle) = E::upgrade_from(&entity) { let event = event.downcast_ref().expect("invalid event type"); on_event(handle, event, cx); @@ -421,7 +421,8 @@ impl<'a> WindowContext<'a> { }))) } else { let handle = self.window.handle; - self.app.run_on_main(move |cx| cx.update_window(handle, f)) + self.app + .run_on_main(move |cx| cx.update_window(handle, |_, cx| f(cx))) } } @@ -443,12 +444,12 @@ impl<'a> WindowContext<'a> { return; } } else { - let async_cx = cx.to_async(); + let mut async_cx = cx.to_async(); cx.next_frame_callbacks.insert(display_id, vec![f]); cx.platform().set_display_link_output_callback( display_id, Box::new(move |_current_time, _output_time| { - let _ = async_cx.update(|cx| { + let _ = async_cx.update(|_, cx| { let callbacks = cx .next_frame_callbacks .get_mut(&display_id) @@ -1181,7 +1182,7 @@ impl<'a> WindowContext<'a> { let window_handle = self.window.handle; self.global_observers.insert( TypeId::of::(), - Box::new(move |cx| cx.update_window(window_handle, |cx| f(cx)).is_ok()), + Box::new(move |cx| cx.update_window(window_handle, |_, cx| f(cx)).is_ok()), ) } @@ -1297,10 +1298,11 @@ impl Context for WindowContext<'_> { fn update_window(&mut self, window: AnyWindowHandle, update: F) -> Result where - F: FnOnce(&mut Self::WindowContext<'_>) -> T, + F: FnOnce(AnyView, &mut Self::WindowContext<'_>) -> T, { if window == self.window.handle { - Ok(update(self)) + let root_view = self.window.root_view.clone().unwrap(); + Ok(update(root_view, self)) } else { self.app.update_window(window, update) } @@ -1310,13 +1312,6 @@ impl Context for WindowContext<'_> { impl VisualContext for WindowContext<'_> { type ViewContext<'a, V: 'static> = ViewContext<'a, V>; - fn root_view(&self) -> Self::Result { - self.window - .root_view - .clone() - .expect("we only take the root_view value when we draw") - } - fn build_view( &mut self, build_view_state: impl FnOnce(&mut Self::ViewContext<'_, V>) -> V, @@ -1654,7 +1649,7 @@ impl<'a, V: 'static> ViewContext<'a, V> { self.app.observers.insert( entity_id, Box::new(move |cx| { - cx.update_window(window_handle, |cx| { + cx.update_window(window_handle, |_, cx| { if let Some(handle) = E::upgrade_from(&entity) { view.update(cx, |this, cx| on_notify(this, handle, cx)) .is_ok() @@ -1683,7 +1678,7 @@ impl<'a, V: 'static> ViewContext<'a, V> { self.app.event_listeners.insert( entity_id, Box::new(move |event, cx| { - cx.update_window(window_handle, |cx| { + cx.update_window(window_handle, |_, cx| { if let Some(handle) = E::upgrade_from(&handle) { let event = event.downcast_ref().expect("invalid event type"); view.update(cx, |this, cx| on_event(this, handle, event, cx)) @@ -1707,7 +1702,7 @@ impl<'a, V: 'static> ViewContext<'a, V> { Box::new(move |this, cx| { let this = this.downcast_mut().expect("invalid entity type"); // todo!("are we okay with silently swallowing the error?") - let _ = cx.update_window(window_handle, |cx| on_release(this, cx)); + let _ = cx.update_window(window_handle, |_, cx| on_release(this, cx)); }), ) } @@ -1729,7 +1724,7 @@ impl<'a, V: 'static> ViewContext<'a, V> { entity_id, Box::new(move |entity, cx| { let entity = entity.downcast_mut().expect("invalid entity type"); - let _ = cx.update_window(window_handle, |cx| { + let _ = cx.update_window(window_handle, |_, cx| { view.update(cx, |this, cx| on_release(this, entity, cx)) }); }), @@ -1892,7 +1887,7 @@ impl<'a, V: 'static> ViewContext<'a, V> { self.global_observers.insert( TypeId::of::(), Box::new(move |cx| { - cx.update_window(window_handle, |cx| { + cx.update_window(window_handle, |_, cx| { view.update(cx, |view, cx| f(view, cx)).is_ok() }) .unwrap_or(false) @@ -1962,7 +1957,7 @@ impl Context for ViewContext<'_, V> { fn update_window(&mut self, window: AnyWindowHandle, update: F) -> Result where - F: FnOnce(&mut Self::WindowContext<'_>) -> T, + F: FnOnce(AnyView, &mut Self::WindowContext<'_>) -> T, { self.window_cx.update_window(window, update) } @@ -1971,10 +1966,6 @@ impl Context for ViewContext<'_, V> { impl VisualContext for ViewContext<'_, V> { type ViewContext<'a, W: 'static> = ViewContext<'a, W>; - fn root_view(&self) -> Self::Result { - self.window_cx.root_view() - } - fn build_view( &mut self, build_view: impl FnOnce(&mut Self::ViewContext<'_, W>) -> W, @@ -2043,21 +2034,24 @@ impl WindowHandle { } } - pub fn update_root( + pub fn update_root( &self, cx: &mut C, - update: impl FnOnce(&mut V, &mut ViewContext) -> R, + update: impl FnOnce( + &mut V, + &mut as VisualContext>::ViewContext<'_, V>, + ) -> R, ) -> Result where - C: Context, + C: for<'a> Context = W>, + W: VisualContext = R>, { - cx.update_window(self.any_handle, |cx| { - let x = Ok(cx.root_view()).flatten(); - - // let root_view = x.unwrap().downcast::().unwrap(); - // root_view.update(cx, update) - todo!() - }) + cx.update_window(self.any_handle, |root_view, cx| { + let view = root_view + .downcast::() + .map_err(|_| anyhow!("the type of the window's root view has changed"))?; + Ok(view.update(cx, update)) + })? } } diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rs index e2413c819cf3807760a941a457f02c8223486df9..2db525a26de86448939ce0af6c21437abe81afac 100644 --- a/crates/workspace2/src/workspace2.rs +++ b/crates/workspace2/src/workspace2.rs @@ -14,7 +14,7 @@ use crate::persistence::model::{ DockData, DockStructure, SerializedItem, SerializedPane, SerializedPaneGroup, SerializedWorkspace, }; -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, Context as _, Result}; use call2::ActiveCall; use client2::{ proto::{self, PeerId}, @@ -29,7 +29,7 @@ use futures::{ }; use gpui2::{ div, point, size, AnyModel, AnyView, AppContext, AsyncAppContext, AsyncWindowContext, Bounds, - Div, EventEmitter, GlobalPixels, MainThread, Model, ModelContext, Point, Render, Size, + Context, Div, EventEmitter, GlobalPixels, MainThread, Model, ModelContext, Point, Render, Size, Subscription, Task, View, ViewContext, VisualContext, WeakView, WindowBounds, WindowContext, WindowHandle, WindowOptions, }; @@ -837,7 +837,7 @@ impl Workspace { }; let window = if let Some(window) = requesting_window { - cx.update_window(window.into(), |cx| { + cx.update_window(window.into(), |old_workspace, cx| { cx.replace_root_view(|cx| { Workspace::new(workspace_id, project_handle.clone(), app_state.clone(), cx) });