mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
config: if window-save-state is never, never restore state
This commit is contained in:
@ -48,12 +48,6 @@ class TerminalWindowRestoration: NSObject, NSWindowRestoration {
|
|||||||
return
|
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
|
// 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.
|
// then something is royally fucked up but protect against it anyhow.
|
||||||
guard let appDelegate = NSApplication.shared.delegate as? AppDelegate else {
|
guard let appDelegate = NSApplication.shared.delegate as? AppDelegate else {
|
||||||
@ -61,6 +55,19 @@ class TerminalWindowRestoration: NSObject, NSWindowRestoration {
|
|||||||
return
|
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
|
// The window creation has to go through our terminalManager so that it
|
||||||
// can be found for events from libghostty. This uses the low-level
|
// can be found for events from libghostty. This uses the low-level
|
||||||
// createWindow so that AppKit can place the window wherever it should
|
// createWindow so that AppKit can place the window wherever it should
|
||||||
|
@ -575,9 +575,14 @@ keybind: Keybinds = .{},
|
|||||||
/// - "never" will never save window state.
|
/// - "never" will never save window state.
|
||||||
/// - "always" will always save window state whenever Ghostty is exited.
|
/// - "always" will always save window state whenever Ghostty is exited.
|
||||||
///
|
///
|
||||||
/// If you change this value so that window state is NOT saved while
|
/// If you change this value to "never" while Ghostty is not running,
|
||||||
/// window state is already saved, the next Ghostty launch will NOT restore
|
/// the next Ghostty launch will NOT restore the window state.
|
||||||
/// the window state.
|
///
|
||||||
|
/// If you change this value to "default" while Ghostty is not running
|
||||||
|
/// and the previous exit saved state, the next Ghostty launch will
|
||||||
|
/// still restore the window state. This is because Ghostty cannot know
|
||||||
|
/// if the previous exit was due to a forced save or not (macOS doesn't
|
||||||
|
/// provide this information).
|
||||||
///
|
///
|
||||||
/// If you change this value so that window state is saved while Ghostty
|
/// If you change this value so that window state is saved while Ghostty
|
||||||
/// is not running, the previous window state will not be restored because
|
/// is not running, the previous window state will not be restored because
|
||||||
|
Reference in New Issue
Block a user