From 7ceb5e815e0050a14f922bc36e33d17a8622474f Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 18 Nov 2022 17:18:23 -0800 Subject: [PATCH] workspace level integration of serialization complete! Time for item level integration.... Co-Authored-By: kay@zed.dev --- crates/workspace/src/persistence.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/workspace/src/persistence.rs b/crates/workspace/src/persistence.rs index 3f04e50461..772e98f84b 100644 --- a/crates/workspace/src/persistence.rs +++ b/crates/workspace/src/persistence.rs @@ -211,13 +211,13 @@ impl WorkspaceDb { &self, workspace_id: &WorkspaceId, ) -> Result { - self.get_pane_group_children(workspace_id, None)? + self.get_pane_group(workspace_id, None)? .into_iter() .next() .context("No center pane group") } - fn get_pane_group_children( + fn get_pane_group( &self, workspace_id: &WorkspaceId, group_id: Option, @@ -254,7 +254,7 @@ impl WorkspaceDb { if let Some((group_id, axis)) = group_id.zip(axis) { Ok(SerializedPaneGroup::Group { axis, - children: self.get_pane_group_children( + children: self.get_pane_group( workspace_id, Some(group_id), )?, @@ -265,6 +265,14 @@ impl WorkspaceDb { bail!("Pane Group Child was neither a pane group or a pane"); } }) + // Filter out panes and pane groups which don't have any children or items + .filter(|pane_group| { + match pane_group { + Ok(SerializedPaneGroup::Group { children, .. }) => !children.is_empty(), + Ok(SerializedPaneGroup::Pane(pane)) => !pane.children.is_empty(), + _ => true, + } + }) .collect::>() }