Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

The sidebar's Move to Space follows the open tab, like Arc (#102)

Victor Kildahl549ab698802d
diff --git a/Sources/Cra/Services/SidebarStore.swift b/Sources/Cra/Services/SidebarStore.swift
index ec5a841..0beb0e0 100644
--- a/Sources/Cra/Services/SidebarStore.swift
+++ b/Sources/Cra/Services/SidebarStore.swift
@@ -969,6 +969,16 @@ final class SidebarStore {
return true
}
+ /// The sidebar's Move to: the tab the window has open (or its split) takes the window
+ /// along, as in Arc (#86); any other tab moves on its own.
+ func moveTab(_ id: UUID, toSpace sid: UUID, window: UUID?) {
+ if let open = selectedTabID(window: window), open == id || splitContaining(open)?.id == id {
+ moveTabAndFollow(open, toSpace: sid, window: window)
+ } else {
+ moveTab(id, toSpace: sid)
+ }
+ }
+
// MARK: Folders
@discardableResult
diff --git a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
index 6ea4963..0b48bfd 100644
--- a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
+++ b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
@@ -89,7 +89,7 @@ enum SidebarMenus {
let spaces = submenu(menu, "Move to Space")
let current = store.spaceID(ofItem: id)
for s in store.orderedSpaces {
- add(spaces, "\(s.emoji) \(s.title)", enabled: s.id != current) { store.moveTab(id, toSpace: s.id) }
+ add(spaces, "\(s.emoji) \(s.title)", enabled: s.id != current) { store.moveTab(id, toSpace: s.id, window: ui.windowID) }
}
folderItems(menu, [id], list: list)
menu.addItem(.separator())
@@ -266,7 +266,7 @@ enum SidebarMenus {
let spaces = submenu(menu, "Move to")
let current = store.spaceID(ofItem: id)
for s in store.orderedSpaces {
- add(spaces, "\(s.emoji) \(s.title)", on: s.id == current) { if s.id != current { store.moveTab(id, toSpace: s.id) } }
+ add(spaces, "\(s.emoji) \(s.title)", on: s.id == current) { if s.id != current { store.moveTab(id, toSpace: s.id, window: ui.windowID) } }
}
menu.addItem(.separator())
add(menu, "Archive Item") { for c in children { store.archiveTab(c, reason: .manual) } }
diff --git a/Tests/StoreTests.swift b/Tests/StoreTests.swift
index 0db08dc..6738fa8 100644
--- a/Tests/StoreTests.swift
+++ b/Tests/StoreTests.swift
@@ -370,9 +370,21 @@ enum StoreTests {
expect(store.focusedSpaceID == work && store.selectedTabID == right.id, "with the same pane focused")
store.selectTab(stay.id)
- store.moveTab(stay.id, toSpace: work)
- expect(store.focusedSpaceID == home && store.selectedTabID(in: home) != stay.id,
- "the context menu's move stays in the space and opens another tab there")
+ let background = store.createTab(url: "https://example.com/background", select: false)
+ store.moveTab(background.id, toSpace: work, window: nil)
+ expect(store.spaceID(ofItem: background.id) == work && store.focusedSpaceID == home && store.selectedTabID == stay.id,
+ "the sidebar's Move to on another tab moves it and stays")
+ store.moveTab(stay.id, toSpace: work, window: nil)
+ expect(store.focusedSpaceID == work && store.selectedTabID == stay.id && store.selectedTabID(in: home) != stay.id,
+ "on the open tab it takes the window along, like Arc")
+ store.selectTab(right.id)
+ store.moveTab(split.id, toSpace: home, window: nil)
+ expect(store.spaceID(ofItem: split.id) == home && store.focusedSpaceID == home && store.selectedTabID == right.id,
+ "and on the open tab's split too")
+
+ store.moveTab(split.id, toSpace: work)
+ expect(store.focusedSpaceID == home && store.selectedTabID(in: home) != right.id,
+ "a move that doesn't follow (a drop on a space) opens another tab in the space it left")
let incognito = store.addIncognitoWindow(frame: nil)
let secret = store.createTab(url: "https://example.com/secret", window: incognito.id)
diff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.md
index 3558a47..f169cfb 100644
--- a/docs/arc-reverse-engineering.md
+++ b/docs/arc-reverse-engineering.md
@@ -2124,9 +2124,11 @@ Two new Arc windows, both with View ▸ Hide Sidebar and a tab selected, capture
the old list, then plays the ordinary space switch (list slides, theme cross-fades, ~300 ms): the window follows
the tab, which sits at the top of the new space's Today, selected, page unchanged. Recording `arc-move.mov`
(scratch, 40 fps), not kept.
-- [U] What the space the tab left selects afterwards, and whether the sidebar's Move to ▸ also follows: other
+- Reported by Anoninz on #86, not captured here: the sidebar's right-click Move to ▸ <space> on the open tab
+ follows too (the row leaves, Arc switches to that space and selects the tab).
+- [U] What the space the tab left selects afterwards, and what Move to ▸ does on a tab that isn't open: other
sessions were driving Arc at the time and a posted ⌃2 never reached the window.
- Cra: `SidebarStore.moveTabAndFollow` for the command bar's Move Tab to <space> and the new Move Tab to Space N
(⌃⌘1–9, Cra's own: ⌘ added to Go to Space N; neither Arc nor macOS binds ⌃⌘ + a digit). A pane brings its split.
- The sidebar menu's Move to Space keeps the window where it is. Whatever moves, a window that had it open in the
+ The sidebar menu's Move to Space follows when it moves the open tab or its split; another tab moves on its own. Whatever moves, a window that had it open in the
old space opens the next tab there, picked as on close.