From 860f1f635cd82dbbffd1c9a9d67d20cccd5d1442 Mon Sep 17 00:00:00 2001 From: Albert Dong Date: Thu, 16 Jan 2025 14:14:48 -0800 Subject: [PATCH 1/2] Manually call orderOut on terminal close alert Allowing the alert to be automatically closed after the completion handler finishes doesn't seem to play well when the completion handler closes the window on which the alert is attached --- macos/Sources/Features/Terminal/BaseTerminalController.swift | 2 +- macos/Sources/Ghostty/Ghostty.TerminalSplit.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/macos/Sources/Features/Terminal/BaseTerminalController.swift b/macos/Sources/Features/Terminal/BaseTerminalController.swift index bda6d62bf..0c5b50b53 100644 --- a/macos/Sources/Features/Terminal/BaseTerminalController.swift +++ b/macos/Sources/Features/Terminal/BaseTerminalController.swift @@ -449,9 +449,9 @@ class BaseTerminalController: NSWindowController, alert.addButton(withTitle: "Cancel") alert.alertStyle = .warning alert.beginSheetModal(for: window, completionHandler: { response in - self.alert = nil switch (response) { case .alertFirstButtonReturn: + alert.window.orderOut(nil) window.close() default: diff --git a/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift b/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift index cc3bef149..cec178245 100644 --- a/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift +++ b/macos/Sources/Ghostty/Ghostty.TerminalSplit.swift @@ -205,6 +205,7 @@ extension Ghostty { alert.beginSheetModal(for: window, completionHandler: { response in switch (response) { case .alertFirstButtonReturn: + alert.window.orderOut(nil) node = nil default: From da5ac6aeeb07efbb2f3acbb5f9a73e601d8cacad Mon Sep 17 00:00:00 2001 From: Albert Dong Date: Thu, 16 Jan 2025 20:57:41 -0800 Subject: [PATCH 2/2] Set alert to nil when modal interacted with --- macos/Sources/Features/Terminal/BaseTerminalController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/macos/Sources/Features/Terminal/BaseTerminalController.swift b/macos/Sources/Features/Terminal/BaseTerminalController.swift index 0c5b50b53..bace20f05 100644 --- a/macos/Sources/Features/Terminal/BaseTerminalController.swift +++ b/macos/Sources/Features/Terminal/BaseTerminalController.swift @@ -449,6 +449,7 @@ class BaseTerminalController: NSWindowController, alert.addButton(withTitle: "Cancel") alert.alertStyle = .warning alert.beginSheetModal(for: window, completionHandler: { response in + self.alert = nil switch (response) { case .alertFirstButtonReturn: alert.window.orderOut(nil)