File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2003,17 +2003,28 @@ class TabManager: ObservableObject {
20032003 placementOverride: NewWorkspacePlacement ? = nil
20042004 ) -> Int {
20052005 let placement = placementOverride ?? WorkspacePlacementSettings . current ( )
2006- let pinnedCount = snapshot. tabs. filter { $0. isPinned } . count
2007- let selectedIndex = snapshot. selectedTabId. flatMap { tabId in
2008- snapshot. tabs. firstIndex ( where: { $0. id == tabId } )
2006+ let tabs = snapshot. tabs
2007+ var pinnedCount = 0
2008+ var selectedIndex : Int ?
2009+ var selectedIsPinned = false
2010+ let selectedTabId = snapshot. selectedTabId
2011+
2012+ for (index, tab) in tabs. enumerated ( ) {
2013+ if tab. isPinned {
2014+ pinnedCount += 1
2015+ }
2016+ if selectedIndex == nil , tab. id == selectedTabId {
2017+ selectedIndex = index
2018+ selectedIsPinned = tab. isPinned
2019+ }
20092020 }
2010- let selectedIsPinned = selectedIndex . map { snapshot . tabs [ $0 ] . isPinned } ?? false
2021+
20112022 return WorkspacePlacementSettings . insertionIndex (
20122023 placement: placement,
20132024 selectedIndex: selectedIndex,
20142025 selectedIsPinned: selectedIsPinned,
20152026 pinnedCount: pinnedCount,
2016- totalCount: snapshot . tabs. count
2027+ totalCount: tabs. count
20172028 )
20182029 }
20192030
You can’t perform that action at this time.
0 commit comments