Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ internal final class MainSplitViewController: NSSplitViewController, InspectorVi
previewCoordinator.promotePreviewTab()
} else {
previewCoordinator.promotePreviewTab()
coordinator.openTableTab(table.name, isView: isView)
coordinator.openTableTab(table.name, isView: isView, asPreview: false)
}
} else {
coordinator.promotePreviewTab()
coordinator.openTableTab(table.name, isView: isView)
coordinator.openTableTab(table.name, isView: isView, asPreview: false)
}
},
pendingTruncates: sessionPendingTruncatesBinding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private let navigationLogger = Logger(subsystem: "com.TablePro", category: "Main
extension MainContentCoordinator {
// MARK: - Table Tab Opening

func openTableTab(_ tableName: String, showStructure: Bool = false, isView: Bool = false) {
func openTableTab(_ tableName: String, showStructure: Bool = false, isView: Bool = false, asPreview: Bool? = nil) {
let navigationModel = PluginMetadataRegistry.shared.snapshot(
forTypeId: connection.type.pluginTypeId
)?.navigationModel ?? .standard
Expand Down Expand Up @@ -73,8 +73,9 @@ extension MainContentCoordinator {

// If no tabs exist (empty state), add a table tab directly.
// In preview mode, mark it as preview so subsequent clicks replace it.
let usePreview = asPreview ?? AppSettingsManager.shared.tabs.enablePreviewTabs
if tabManager.tabs.isEmpty {
if AppSettingsManager.shared.tabs.enablePreviewTabs {
if usePreview {
tabManager.addPreviewTableTab(
tableName: tableName,
databaseType: connection.type,
Expand Down Expand Up @@ -155,7 +156,7 @@ extension MainContentCoordinator {
}

// Preview tab mode: reuse or create a preview tab instead of a new native window
if AppSettingsManager.shared.tabs.enablePreviewTabs {
if usePreview {
openPreviewTab(tableName, isView: isView, databaseName: currentDatabase, schemaName: currentSchema, showStructure: showStructure)
return
}
Expand Down
17 changes: 13 additions & 4 deletions TablePro/Views/Sidebar/DoubleClickDetector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,22 @@ private final class SharedDoubleClickMonitor {
private func handleMouseDown(_ event: NSEvent) {
guard event.clickCount == 2 else { return }

for view in registeredViews.allObjects {
let views = registeredViews.allObjects
guard !views.isEmpty else { return }

for view in views {
guard let viewWindow = view.window,
event.window === viewWindow else { continue }
let locationInView = view.convert(event.locationInWindow, from: nil)
if view.bounds.contains(locationInView) {

var ancestor: NSView? = view.superview
while let current = ancestor, !(current is NSTableRowView) {
ancestor = current.superview
}
let hitView = ancestor ?? view
let locationInHitView = hitView.convert(event.locationInWindow, from: nil)
if hitView.bounds.contains(locationInHitView) {
view.onDoubleClick?()
break
return
}
}
}
Expand Down
Loading