From fa8bac9714a522a2192d764f51112605bf1b8612 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 13 Sep 2022 11:40:23 -0700 Subject: [PATCH] fixed one failing test --- crates/workspace/src/pane_group.rs | 4 ++++ crates/workspace/src/workspace.rs | 7 ++++++- crates/zed/src/zed.rs | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/workspace/src/pane_group.rs b/crates/workspace/src/pane_group.rs index 0ed7ed111b..94acf427e4 100644 --- a/crates/workspace/src/pane_group.rs +++ b/crates/workspace/src/pane_group.rs @@ -38,6 +38,10 @@ impl PaneGroup { } } + /// Returns: + /// - Ok(true) if it found and removed a pane + /// - Ok(false) if it found but did not remove the pane + /// - Err(_) if it did not find the pane pub fn remove(&mut self, pane: &ViewHandle) -> Result { match &mut self.root { Member::Pane(_) => Ok(false), diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 0f4580947c..0f3920eae0 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -957,6 +957,7 @@ impl Workspace { .detach(); let center_pane = cx.add_view(|cx| Pane::new(None, cx)); + dbg!(¢er_pane); let pane_id = center_pane.id(); cx.subscribe(¢er_pane, move |this, _, event, cx| { this.handle_pane_event(pane_id, event, cx) @@ -992,6 +993,7 @@ impl Workspace { let dock = Dock::new(cx, dock_default_factory); let dock_pane = dock.pane().clone(); + dbg!(&dock_pane); let left_sidebar = cx.add_view(|_| Sidebar::new(SidebarSide::Left)); let right_sidebar = cx.add_view(|_| Sidebar::new(SidebarSide::Right)); @@ -1016,7 +1018,10 @@ impl Workspace { weak_self: weak_handle, center: PaneGroup::new(center_pane.clone()), dock, - panes: vec![center_pane.clone(), dock_pane], + // When removing an item, the last element remaining in this array + // is used to find where focus should fallback to. As such, the order + // of these two variables is important. + panes: vec![dock_pane, center_pane.clone()], panes_by_item: Default::default(), active_pane: center_pane.clone(), last_active_center_pane: Some(center_pane.clone()), diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 883225e4db..fcbd88b74f 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -1228,7 +1228,7 @@ mod tests { cx.foreground().run_until_parked(); workspace.read_with(cx, |workspace, _| { - assert_eq!(workspace.panes().len(), 1); + assert_eq!(workspace.panes().len(), 2); //Center pane + Dock pane assert_eq!(workspace.active_pane(), &pane_1); }); @@ -1238,6 +1238,7 @@ mod tests { cx.foreground().run_until_parked(); workspace.read_with(cx, |workspace, cx| { + assert_eq!(workspace.panes().len(), 2); assert!(workspace.active_item(cx).is_none()); });