Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions TablePro/Views/Sidebar/DatabaseTreeOutlineCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -368,17 +368,23 @@ final class DatabaseTreeOutlineCoordinator: NSObject {
publishedTables = selectedTables
publishedSelectionDatabase = selectionDatabase

/// Matched on the object and scoped to the database on screen, in that order, rather than
/// on the whole reference. The model holds the row the user picked, database included, but
/// browsing elsewhere is meant to move the highlight onto that database's copy of the same
/// object; comparing references pins it to the database it was picked in and leaves the
/// tree with nothing selected the moment the browse cursor moves.
let selectedObjects = Set(selectedTables.map(\.table))
var nodes: [DatabaseTreeNode] = []
for node in nodeCache.values {
guard case .table(let ref) = node.kind, selectedTables.contains(ref) else { continue }
guard case .table(let ref) = node.kind, selectedObjects.contains(ref.table) else { continue }
guard selectionDatabase == nil || ref.database == selectionDatabase else { continue }
nodes.append(node)
}
lastSelectedNodeIds = nodes.map(\.id)
lastSelection = Set(DatabaseTreeSelection.tableRefs(of: nodes))
/// Still pending while a selected table has no row in the database being browsed: the row is
/// usually one that has not been built yet, and the next sync adopts it.
isModelSelectionAdoptionPending = Set(lastSelection) != selectedTables
isModelSelectionAdoptionPending = Set(lastSelection.map(\.table)) != selectedObjects
}

private var modelSelectionDatabase: String? {
Expand Down
Loading