From 6020ce016538a9b23d517a76c10f3f9fba9ac0bc Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Mon, 1 Jun 2026 23:23:16 +0700 Subject: [PATCH] fix(editor): refresh autocomplete when switching schema --- CHANGELOG.md | 1 + TablePro/Views/Main/MainContentCoordinator.swift | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c748b460..29f460ac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - PostgreSQL: the selected schema now stays applied to editor queries after an automatic reconnect, so unqualified table names keep resolving against it instead of falling back to the default schema. (#1540) - Import now detects the Setapp edition of TablePlus and reads connections from its data folder. It was reported as not installed before. (#1528) - Favorite keyword suggestions now show in the editor autocomplete when you type the keyword. They were being dropped before reaching the popup. +- Editor autocomplete now refreshes when you switch schema, so it suggests the new schema's tables and columns instead of the previous one's. ## [0.47.0] - 2026-06-01 diff --git a/TablePro/Views/Main/MainContentCoordinator.swift b/TablePro/Views/Main/MainContentCoordinator.swift index b1bbd0170..1fbf23681 100644 --- a/TablePro/Views/Main/MainContentCoordinator.swift +++ b/TablePro/Views/Main/MainContentCoordinator.swift @@ -192,6 +192,7 @@ final class MainContentCoordinator { @ObservationIgnored private var terminationObserver: NSObjectProtocol? @ObservationIgnored private var postConnectCancellable: AnyCancellable? @ObservationIgnored private var externalFileModCancellable: AnyCancellable? + @ObservationIgnored private var schemaSwitchCancellable: AnyCancellable? var fileConflictRequest: FileConflictRequest? @@ -423,6 +424,15 @@ final class MainContentCoordinator { self.checkOpenTabsForExternalModification() } + schemaSwitchCancellable = services.appEvents.currentSchemaChanged + .receive(on: RunLoop.main) + .sink { [weak self] changedConnectionId in + guard let self, changedConnectionId == self.connectionId else { return } + Task { @MainActor in + await self.refreshTables() + } + } + self.filterCoordinator = FilterCoordinator(parent: self) self.queryExecutionCoordinator = QueryExecutionCoordinator(parent: self) self.paginationCoordinator = PaginationCoordinator(parent: self) @@ -619,6 +629,7 @@ final class MainContentCoordinator { } postConnectCancellable = nil externalFileModCancellable = nil + schemaSwitchCancellable = nil fileWatcher?.stopWatching(connectionId: connectionId) fileWatcher = nil currentQueryTask?.cancel()