From 84f69fefb1ed3863ccc035066dc355742a5e2937 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 11 Apr 2026 16:31:36 +0700 Subject: [PATCH] fix: query tab title incorrectly shows table name after execution (#668) Root cause: updateWindowTitleAndFileState() used tab.tableName as the window title for ALL tab types. After executing SELECT * FROM users, tableName="users" was set (correct for edit support), but the window title also became "users" instead of "Query 1". This caused sidebar "open table" to match the query tab's window by title, switching to it instead of opening a new table tab. Fix: only use tableName as window title for .table tabs. For .query tabs, use tab.title (the stable display name like "Query 1"). --- TablePro/Views/Main/Extensions/MainContentView+Setup.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TablePro/Views/Main/Extensions/MainContentView+Setup.swift b/TablePro/Views/Main/Extensions/MainContentView+Setup.swift index dfcc679e..7149a6ba 100644 --- a/TablePro/Views/Main/Extensions/MainContentView+Setup.swift +++ b/TablePro/Views/Main/Extensions/MainContentView+Setup.swift @@ -161,7 +161,8 @@ extension MainContentView { } else { let langName = PluginManager.shared.queryLanguageName(for: connection.type) let queryLabel = "\(langName) Query" - windowTitle = selectedTab?.tableName + windowTitle = (selectedTab?.tabType == .table ? selectedTab?.tableName : nil) + ?? selectedTab?.title ?? (tabManager.tabs.isEmpty ? connection.name : queryLabel) } viewWindow?.representedURL = selectedTab?.sourceFileURL