@@ -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<Pane>) -> Result<bool> {
match &mut self.root {
Member::Pane(_) => Ok(false),
@@ -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()),
@@ -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());
});