Skip to content

Commit 8aeba44

Browse files
committed
fix: prioritize data grid save over sidebar edits in close-with-save flow
saveAndClose() checked rightPanelState.editState.hasEdits before changeManager.hasChanges, causing it to take the sidebar-only save path (which doesn't execute SQL) when the inspector panel reflected data grid edits. This matched the user's report: Cmd+W → Save behaved identically to Cmd+W → Don't Save. The regular saveChanges() already had the correct priority order (data grid first, sidebar second). This aligns saveAndClose() with that logic.
1 parent c52e3ca commit 8aeba44

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

TablePro/Views/Main/MainContentCommandActions.swift

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -358,22 +358,27 @@ final class MainContentCommandActions {
358358
return
359359
}
360360

361-
// Sidebar edits
361+
// Data grid changes take priority (synced to sidebar editState,
362+
// and the data grid path uses the correct plugin driver for SQL generation)
363+
if coordinator.changeManager.hasChanges {
364+
let saved = await withCheckedContinuation { continuation in
365+
coordinator.saveCompletionContinuation = continuation
366+
saveChanges()
367+
}
368+
if saved {
369+
performClose()
370+
}
371+
return
372+
}
373+
374+
// Sidebar-only edits (made directly in the inspector panel)
362375
if rightPanelState.editState.hasEdits {
363376
rightPanelState.onSave?()
364377
performClose()
365378
return
366379
}
367380

368-
// Data grid changes: await the async save via continuation
369-
let saved = await withCheckedContinuation { continuation in
370-
coordinator.saveCompletionContinuation = continuation
371-
saveChanges()
372-
}
373-
374-
if saved {
375-
performClose()
376-
}
381+
performClose()
377382
}
378383

379384
private func saveFileToSourceURL() {

0 commit comments

Comments
 (0)