From 3b507d361fc35eef394da18fc5a52648ccd41622 Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Sun, 15 Mar 2026 21:48:51 -0700 Subject: [PATCH] fix: require pinned ids in sidebar drop planner (#1505) Co-authored-by: Lawrence Chen --- Sources/ContentView.swift | 4 +-- cmuxTests/CmuxWebViewKeyEquivalentTests.swift | 29 ++++++++++++++----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Sources/ContentView.swift b/Sources/ContentView.swift index 61d50509..c7708c7c 100644 --- a/Sources/ContentView.swift +++ b/Sources/ContentView.swift @@ -11578,7 +11578,7 @@ enum SidebarDropPlanner { draggedTabId: UUID?, targetTabId: UUID?, tabIds: [UUID], - pinnedTabIds: Set = [], + pinnedTabIds: Set, pointerY: CGFloat? = nil, targetHeight: CGFloat? = nil ) -> SidebarDropIndicator? { @@ -11619,7 +11619,7 @@ enum SidebarDropPlanner { targetTabId: UUID?, indicator: SidebarDropIndicator?, tabIds: [UUID], - pinnedTabIds: Set = [] + pinnedTabIds: Set ) -> Int? { guard let fromIndex = tabIds.firstIndex(of: draggedTabId) else { return nil } diff --git a/cmuxTests/CmuxWebViewKeyEquivalentTests.swift b/cmuxTests/CmuxWebViewKeyEquivalentTests.swift index c4831794..5c0ad1af 100644 --- a/cmuxTests/CmuxWebViewKeyEquivalentTests.swift +++ b/cmuxTests/CmuxWebViewKeyEquivalentTests.swift @@ -7166,14 +7166,16 @@ final class SidebarDropPlannerTests: XCTestCase { SidebarDropPlanner.indicator( draggedTabId: first, targetTabId: first, - tabIds: tabIds + tabIds: tabIds, + pinnedTabIds: [] ) ) XCTAssertNil( SidebarDropPlanner.indicator( draggedTabId: third, targetTabId: nil, - tabIds: tabIds + tabIds: tabIds, + pinnedTabIds: [] ) ) } @@ -7184,14 +7186,16 @@ final class SidebarDropPlannerTests: XCTestCase { SidebarDropPlanner.indicator( draggedTabId: only, targetTabId: nil, - tabIds: [only] + tabIds: [only], + pinnedTabIds: [] ) ) XCTAssertNil( SidebarDropPlanner.indicator( draggedTabId: only, targetTabId: only, - tabIds: [only] + tabIds: [only], + pinnedTabIds: [] ) ) } @@ -7205,7 +7209,8 @@ final class SidebarDropPlannerTests: XCTestCase { let indicator = SidebarDropPlanner.indicator( draggedTabId: second, targetTabId: nil, - tabIds: tabIds + tabIds: tabIds, + pinnedTabIds: [] ) XCTAssertEqual(indicator?.tabId, nil) XCTAssertEqual(indicator?.edge, .bottom) @@ -7221,7 +7226,8 @@ final class SidebarDropPlannerTests: XCTestCase { draggedTabId: second, targetTabId: nil, indicator: SidebarDropIndicator(tabId: nil, edge: .bottom), - tabIds: tabIds + tabIds: tabIds, + pinnedTabIds: [] ) XCTAssertEqual(index, 2) } @@ -7236,7 +7242,8 @@ final class SidebarDropPlannerTests: XCTestCase { SidebarDropPlanner.indicator( draggedTabId: second, targetTabId: second, - tabIds: tabIds + tabIds: tabIds, + pinnedTabIds: [] ) ) } @@ -7252,6 +7259,7 @@ final class SidebarDropPlannerTests: XCTestCase { draggedTabId: first, targetTabId: second, tabIds: tabIds, + pinnedTabIds: [], pointerY: 2, targetHeight: 40 ) @@ -7268,6 +7276,7 @@ final class SidebarDropPlannerTests: XCTestCase { draggedTabId: first, targetTabId: second, tabIds: tabIds, + pinnedTabIds: [], pointerY: 38, targetHeight: 40 ) @@ -7278,7 +7287,8 @@ final class SidebarDropPlannerTests: XCTestCase { draggedTabId: first, targetTabId: second, indicator: indicator, - tabIds: tabIds + tabIds: tabIds, + pinnedTabIds: [] ), 1 ) @@ -7294,6 +7304,7 @@ final class SidebarDropPlannerTests: XCTestCase { draggedTabId: third, targetTabId: first, tabIds: tabIds, + pinnedTabIds: [], pointerY: 38, targetHeight: 40 ) @@ -7301,6 +7312,7 @@ final class SidebarDropPlannerTests: XCTestCase { draggedTabId: third, targetTabId: second, tabIds: tabIds, + pinnedTabIds: [], pointerY: 2, targetHeight: 40 ) @@ -7322,6 +7334,7 @@ final class SidebarDropPlannerTests: XCTestCase { draggedTabId: third, targetTabId: second, tabIds: tabIds, + pinnedTabIds: [], pointerY: 38, targetHeight: 40 )