From ae7221d6803a35209b2899d97635d2bb8d7bbdf4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 3 Jan 2024 11:53:18 -0800 Subject: [PATCH] macos: try to save window state before sparkle restart --- macos/Sources/Features/Update/UpdateDelegate.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/macos/Sources/Features/Update/UpdateDelegate.swift b/macos/Sources/Features/Update/UpdateDelegate.swift index c116432df..c462e180d 100644 --- a/macos/Sources/Features/Update/UpdateDelegate.swift +++ b/macos/Sources/Features/Update/UpdateDelegate.swift @@ -1,4 +1,5 @@ import Sparkle +import Cocoa class UpdaterDelegate: NSObject, SPUUpdaterDelegate { func feedURLString(for updater: SPUUpdater) -> String? { @@ -8,4 +9,12 @@ class UpdaterDelegate: NSObject, SPUUpdaterDelegate { // tip appcast URL since it is all we support. return "https://tip.files.ghostty.dev/appcast.xml" } + + func updaterWillRelaunchApplication(_ updater: SPUUpdater) { + // When the updater is relaunching the application we want to get macOS + // to invalidate and re-encode all of our restorable state so that when + // we relaunch it uses it. + NSApp.invalidateRestorableState() + for window in NSApp.windows { window.invalidateRestorableState() } + } }