Skip to content

Commit 07d1dbc

Browse files
committed
fix: guard clearChangesAndUndoHistory with tab ID check
Prevent clearing another tab's undo state when a background query or multi-statement execution completes after the user has switched tabs.
1 parent 260f532 commit 07d1dbc

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

TablePro/Views/Main/Extensions/MainContentCoordinator+MultiStatement.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ extension MainContentCoordinator {
134134
updatedTab.errorMessage = nil
135135
tabManager.tabs[idx] = updatedTab
136136

137-
changeManager.clearChangesAndUndoHistory()
138-
changeManager.reloadVersion += 1
137+
if tabManager.selectedTabId == tabId {
138+
changeManager.clearChangesAndUndoHistory()
139+
changeManager.reloadVersion += 1
140+
}
139141
}
140142
} catch {
141143
// Rollback on failure

TablePro/Views/Main/Extensions/MainContentCoordinator+QueryHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ extension MainContentCoordinator {
192192
// Clear stale edit state immediately so the save banner
193193
// doesn't linger while Phase 2 metadata loads in background.
194194
// Only clear if there are no pending edits from the user.
195-
if isEditable && !changeManager.hasChanges {
195+
if tabManager.selectedTabId == tabId, isEditable, !changeManager.hasChanges {
196196
changeManager.clearChangesAndUndoHistory()
197197
}
198198
}

0 commit comments

Comments
 (0)