From 60e1ca81f070a557e89fd0756077b9d812141fda Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 31 Oct 2023 09:41:40 -0700 Subject: [PATCH] macos: if alert is already showing, don't check if need confirm --- .../Terminal/TerminalController.swift | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index f2b9e832e..6a4ae7afb 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -114,31 +114,32 @@ class TerminalController: NSWindowController, NSWindowDelegate, TerminalViewDele // If we have no surfaces, close. guard let node = self.surfaceTree else { return true } + // If we already have an alert, continue with it + guard alert == nil else { return false } + // If our surfaces don't require confirmation, close. if (!node.needsConfirmQuit()) { return true } // We require confirmation, so show an alert as long as we aren't already. - if (alert == nil) { - let alert = NSAlert() - alert.messageText = "Close Terminal?" - alert.informativeText = "The terminal still has a running process. If you close the " + - "terminal the process will be killed." - alert.addButton(withTitle: "Close the Terminal") - alert.addButton(withTitle: "Cancel") - alert.alertStyle = .warning - alert.beginSheetModal(for: window, completionHandler: { response in - self.alert = nil - switch (response) { - case .alertFirstButtonReturn: - window.close() - - default: - break - } - }) + let alert = NSAlert() + alert.messageText = "Close Terminal?" + alert.informativeText = "The terminal still has a running process. If you close the " + + "terminal the process will be killed." + alert.addButton(withTitle: "Close the Terminal") + alert.addButton(withTitle: "Cancel") + alert.alertStyle = .warning + alert.beginSheetModal(for: window, completionHandler: { response in + self.alert = nil + switch (response) { + case .alertFirstButtonReturn: + window.close() + + default: + break + } + }) - self.alert = alert - } + self.alert = alert return false }