Skip to content

Commit babcbcf

Browse files
committed
workspace: sanitize pinned tab count before usage
Fixes all sorts of panics around usage of incorrect pinned tab count that has been fixed in app itself, yet persists in user db.
1 parent 4e12f05 commit babcbcf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/workspace/src/pane.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ impl Pane {
755755
}
756756

757757
pub(crate) fn set_pinned_count(&mut self, count: usize) {
758-
self.pinned_tab_count = count;
758+
self.pinned_tab_count = count.min(self.items.len());
759759
}
760760

761761
pub(crate) fn pinned_count(&self) -> usize {
@@ -1890,7 +1890,7 @@ impl Pane {
18901890
fn unpin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<'_, Self>) {
18911891
maybe!({
18921892
let pane = cx.view().clone();
1893-
self.pinned_tab_count = self.pinned_tab_count.checked_sub(1).unwrap();
1893+
self.pinned_tab_count = self.pinned_tab_count.checked_sub(1)?;
18941894
let destination_index = self.pinned_tab_count;
18951895

18961896
let id = self.item_for_index(ix)?.item_id();

0 commit comments

Comments
 (0)