Skip to content

Commit

Permalink
workspace: Sanitize pinned tab count before usage (cherry-pick #21417) (
Browse files Browse the repository at this point in the history
#21422)

Cherry-picked 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

Co-authored-by: Piotr Osiewicz <[email protected]>
  • Loading branch information
gcp-cherry-pick-bot[bot] and osiewicz authored Dec 2, 2024
1 parent 088fc85 commit 721cce2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/workspace/src/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,7 @@ impl Pane {
fn unpin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<'_, Self>) {
maybe!({
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 id = self.item_for_index(ix)?.item_id();
Expand Down
2 changes: 1 addition & 1 deletion crates/workspace/src/persistence/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl SerializedPane {
})?;
}
pane.update(cx, |pane, _| {
pane.set_pinned_count(self.pinned_count);
pane.set_pinned_count(self.pinned_count.min(items.len()));
})?;

anyhow::Ok(items)
Expand Down

0 comments on commit 721cce2

Please sign in to comment.