fix crash when opening files via Finder before appState init

This commit is contained in:
jess 2026-04-06 14:30:36 -07:00
parent df35ed406e
commit 9c8589de03
1 changed files with 12 additions and 1 deletions

View File

@ -41,11 +41,22 @@ class AppDelegate: NSObject, NSApplicationDelegate {
self, selector: #selector(settingsDidChange),
name: .settingsChanged, object: nil
)
if let url = pendingOpenURLs.first {
pendingOpenURLs = []
appState.loadNoteFromFile(url)
}
}
private var pendingOpenURLs: [URL] = []
func application(_ application: NSApplication, open urls: [URL]) {
guard let url = urls.first else { return }
if appState != nil {
appState.loadNoteFromFile(url)
} else {
pendingOpenURLs = [url]
}
}
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {