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
This commit is contained in:
Piotr Osiewicz 2024-12-02 19:56:52 +01:00 committed by GitHub
parent 95a047c11b
commit f32ffcf5bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -1890,7 +1890,7 @@ impl Pane {
fn unpin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<'_, Self>) { fn unpin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<'_, Self>) {
maybe!({ maybe!({
let pane = cx.view().clone(); let pane = cx.view().clone();
self.pinned_tab_count = self.pinned_tab_count.checked_sub(1).unwrap(); self.pinned_tab_count = self.pinned_tab_count.checked_sub(1)?;
let destination_index = self.pinned_tab_count; let destination_index = self.pinned_tab_count;
let id = self.item_for_index(ix)?.item_id(); let id = self.item_for_index(ix)?.item_id();

View file

@ -473,7 +473,7 @@ impl SerializedPane {
})?; })?;
} }
pane.update(cx, |pane, _| { pane.update(cx, |pane, _| {
pane.set_pinned_count(self.pinned_count); pane.set_pinned_count(self.pinned_count.min(items.len()));
})?; })?;
anyhow::Ok(items) anyhow::Ok(items)