From 975cd9e93eb3ad915378de48668593ff4a557aa5 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Tue, 24 Jun 2025 16:24:06 -0400 Subject: [PATCH] Patch panic around pinned tab count (#33335) After much investigation, I have not been able to track down what is causing [this panic](https://github.com/zed-industries/zed/issues/33342). I'm clamping the value for now, because a bug is better than a crash. Hopefully someone finds reproduction steps, and I will implement a proper fix. Release Notes: - N/A --- crates/workspace/src/pane.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 940c9eb04ff0aeb06c63e7760cfc076251015fb5..d634ed1353cdeb397890acb2940f0243bd1a0ee6 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -2790,7 +2790,19 @@ impl Pane { }) .collect::>(); let tab_count = tab_items.len(); - let unpinned_tabs = tab_items.split_off(self.pinned_tab_count); + let safe_pinned_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, \ + in a comment, to https://github.com/zed-industries/zed/issues/33342", + self.pinned_tab_count, + tab_count + ); + tab_count + } else { + self.pinned_tab_count + }; + let unpinned_tabs = tab_items.split_off(safe_pinned_count); let pinned_tabs = tab_items; TabBar::new("tab_bar") .when(