config: if window-save-state is never, never restore state

This commit is contained in:
Mitchell Hashimoto
2023-12-22 21:58:29 -08:00
parent f0bf0fd888
commit a5d249eb48
2 changed files with 21 additions and 9 deletions

View File

@@ -48,12 +48,6 @@ class TerminalWindowRestoration: NSObject, NSWindowRestoration {
return
}
// Decode the state. If we can't decode the state, then we can't restore.
guard let state = TerminalRestorableState(coder: state) else {
completionHandler(nil, RestoreError.stateDecodeFailed)
return
}
// The app delegate is definitely setup by now. If it isn't our AppDelegate
// then something is royally fucked up but protect against it anyhow.
guard let appDelegate = NSApplication.shared.delegate as? AppDelegate else {
@@ -61,6 +55,19 @@ class TerminalWindowRestoration: NSObject, NSWindowRestoration {
return
}
// If our configuration is "never" then we never restore the state
// no matter what.
if (appDelegate.terminalManager.ghostty.windowSaveState == "never") {
completionHandler(nil, nil)
return
}
// Decode the state. If we can't decode the state, then we can't restore.
guard let state = TerminalRestorableState(coder: state) else {
completionHandler(nil, RestoreError.stateDecodeFailed)
return
}
// The window creation has to go through our terminalManager so that it
// can be found for events from libghostty. This uses the low-level
// createWindow so that AppKit can place the window wherever it should