Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix edge case where the welcome page might open in the dock if the user's actions race the welcome experience action
Mikayla Maki1f6bd0ea7758
diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 442d28579fc..cd2cd6fccb3 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -1349,6 +1349,23 @@ impl Workspace {pane}+ pub fn add_item_to_center(+ &mut self,+ item: Box<dyn ItemHandle>,+ cx: &mut ViewContext<Self>,+ ) -> bool {+ if let Some(center_pane) = self.last_active_center_pane.clone() {+ if let Some(center_pane) = center_pane.upgrade(cx) {+ Pane::add_item(self, ¢er_pane, item, true, true, None, cx);+ true+ } else {+ false+ }+ } else {+ false+ }+ }+pub fn add_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut ViewContext<Self>) {let active_pane = self.active_pane().clone();Pane::add_item(self, &active_pane, item, true, true, None, cx);diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rsindex 5d13d41bba0..a9032a264ba 100644--- a/crates/zed/src/zed.rs+++ b/crates/zed/src/zed.rs@@ -266,7 +266,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {open_new(&app_state, cx, |workspace, cx| {workspace.toggle_sidebar(SidebarSide::Left, cx);let welcome_page = cx.add_view(|cx| welcome::WelcomePage::new(cx));- workspace.add_item(Box::new(welcome_page.clone()), cx);+ workspace.add_item_to_center(Box::new(welcome_page.clone()), cx);Dock::move_dock(workspace, settings::DockAnchor::Bottom, false, cx);cx.focus(welcome_page);cx.notify();