From 8f9817173d749183966e1c9ac526baf5d720730d Mon Sep 17 00:00:00 2001 From: vipex <101529155+vipexv@users.noreply.github.com> Date: Wed, 25 Jun 2025 21:52:15 +0200 Subject: [PATCH] pane: Update pinned tab count when it exceeds actual tab count (#33405) ## Summary This PR improves the workaround introduced in #33335 that handles cases where the pinned tab count exceeds the actual tab count during workspace deserialization. ## Problem The original workaround in #33335 successfully prevented the panic but had two issues: 1. **Console spam**: The warning message was logged repeatedly because `self.pinned_tab_count` wasn't updated to match the actual tab count 2. **Auto-pinning behavior**: New tabs up until you exceed the old safe tab count were automatically pinned after the workaround was triggered. ## Solution Updates the defensive code to set `self.pinned_tab_count = tab_count` when the mismatch is detected, ensuring: - The warning is only logged once when encountered. - New tabs behave normally (aren't auto-pinned) - The workspace remains in a consistent state This is an immediate fix for the workaround. I'll attempt to open up a follow-up PR when i get the chance that will address the root cause by implementing serialization for empty untitled tabs, as discussed in #33342. Release Notes: - N/A --- crates/workspace/src/pane.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 9644ef9e7967529098129a73d30442f800c391ad..5c04912d6b07e236652d04a220f00038287a76e6 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -2784,7 +2784,7 @@ impl Pane { }) .collect::>(); let tab_count = tab_items.len(); - let safe_pinned_count = if self.pinned_tab_count > tab_count { + if self.pinned_tab_count > tab_count { log::warn!( "Pinned tab count ({}) exceeds actual tab count ({}). \ This should not happen. If possible, add reproduction steps, \ @@ -2792,11 +2792,9 @@ impl Pane { self.pinned_tab_count, tab_count ); - tab_count - } else { - self.pinned_tab_count - }; - let unpinned_tabs = tab_items.split_off(safe_pinned_count); + self.pinned_tab_count = tab_count; + } + let unpinned_tabs = tab_items.split_off(self.pinned_tab_count); let pinned_tabs = tab_items; TabBar::new("tab_bar") .when(