From 395798ecb4676baa2441104c97a65be1a76d525f Mon Sep 17 00:00:00 2001 From: Kunall Banerjee Date: Mon, 16 Mar 2026 17:36:48 -0400 Subject: [PATCH] workspace: Fix pinned count when restoring panes with failed items When deserializing panes, some items may fail to load and become `None`. The pinned count should only include successfully loaded items, not the original count which may exceed the number of actual items. --- crates/workspace/src/persistence/model.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/workspace/src/persistence/model.rs b/crates/workspace/src/persistence/model.rs index c5251f20be9313a50f2256c54823d8839bdfe7fd..c7171116ed703d337fc53a86999f6284b4bcb011 100644 --- a/crates/workspace/src/persistence/model.rs +++ b/crates/workspace/src/persistence/model.rs @@ -351,8 +351,17 @@ impl SerializedPane { } })?; } + + // `items` contains `None` for each item that failed to deserialize. + // Only `Some` entries are added to the pane above, so the pinned + // count must only count those — not the total serialized count. + let pinned_count = items + .iter() + .take(self.pinned_count) + .filter(|item| item.is_some()) + .count(); pane.update(cx, |pane, _| { - pane.set_pinned_count(self.pinned_count.min(items.len())); + pane.set_pinned_count(pinned_count); })?; anyhow::Ok(items)