Skip to content

Commit d2894ce

Browse files
authored
pane: Do not autopin new item created as a neighbour of pinned tab (#18072)
When I used editor::NewFile or ProjectSearch from a pinned tab, the resulting new tab would be pinned (and the last pinned tab would be pushed off). This PR fixes it by always storing new tabs outside of the pinned area if there's no destination index for the new tab. Release Notes: - Fixed tab bar not preserving pinned tab state when an editor::NewFile action is executed.
1 parent d91e625 commit d2894ce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crates/workspace/src/pane.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,13 +831,14 @@ impl Pane {
831831
}
832832
}
833833
}
834-
// If no destination index is specified, add or move the item after the active item.
834+
// If no destination index is specified, add or move the item after the
835+
// active item (or at the start of tab bar, if the active item is pinned)
835836
let mut insertion_index = {
836837
cmp::min(
837838
if let Some(destination_index) = destination_index {
838839
destination_index
839840
} else {
840-
self.active_item_index + 1
841+
cmp::max(self.active_item_index + 1, self.pinned_count())
841842
},
842843
self.items.len(),
843844
)

0 commit comments

Comments
 (0)