Skip to content

Commit f32ffcf

Browse files
authored
workspace: Sanitize pinned tab count before usage (#21417)
Fixes all sorts of panics around usage of incorrect pinned tab count that has been fixed in app itself, yet persists in user db. Closes #ISSUE Release Notes: - N/A
1 parent 95a047c commit f32ffcf

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

crates/workspace/src/pane.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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();

crates/workspace/src/persistence/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl SerializedPane {
473473
})?;
474474
}
475475
pane.update(cx, |pane, _| {
476-
pane.set_pinned_count(self.pinned_count);
476+
pane.set_pinned_count(self.pinned_count.min(items.len()));
477477
})?;
478478

479479
anyhow::Ok(items)

0 commit comments

Comments
 (0)