From 3182e13e75149c9b99e610f9b8a49fa7adea6ecf Mon Sep 17 00:00:00 2001 From: Axel Carlsson Date: Wed, 23 Oct 2024 11:10:53 +0200 Subject: [PATCH] fix: Exclude pinned tabs when closing all items This fix is only for closing all items. It could easily be expanded to also handle closes to left and right. --- crates/workspace/src/pane.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 6b99401f050e8e..884603638db863 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -1206,11 +1206,25 @@ impl Pane { return None; } - Some( - self.close_items(cx, action.save_intent.unwrap_or(SaveIntent::Close), |_| { - true - }), - ) + // Close all un-pinned tabs. + let items_to_close: Vec<_> = self + .items + .iter() + .map(|item| item.item_id()) + .filter(|item_id| { + if let Some(ix) = self.index_for_item_id(*item_id) { + !self.is_tab_pinned(ix) + } else { + true + } + }) + .collect(); + + Some(self.close_items( + cx, + action.save_intent.unwrap_or(SaveIntent::Close), + |item_id| items_to_close.contains(&item_id), + )) } pub(super) fn file_names_for_prompt(