Skip to content

Commit

Permalink
workspace: sanitize pinned tab count before usage
Browse files Browse the repository at this point in the history
Fixes all sorts of panics around usage of incorrect pinned tab count that has been fixed in app itself, yet persists in user db.
  • Loading branch information
osiewicz committed Dec 2, 2024
1 parent 4e12f05 commit babcbcf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/workspace/src/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ impl Pane {
}

pub(crate) fn set_pinned_count(&mut self, count: usize) {
self.pinned_tab_count = count;
self.pinned_tab_count = count.min(self.items.len());
}

pub(crate) fn pinned_count(&self) -> usize {
Expand Down Expand Up @@ -1890,7 +1890,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

0 comments on commit babcbcf

Please sign in to comment.