From e6c77789d341742aa80d7387cfba67bba9843b75 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 17 Jun 2025 15:02:59 -0700 Subject: [PATCH] macOS: Confirm close on window close Fixes #7615 We were incorrectly closing the window without confirmation when there were no tabs. --- .../Features/Terminal/TerminalController.swift | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 03a4e548e..2e4fb7363 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -1001,20 +1001,14 @@ class TerminalController: BaseTerminalController { @IBAction override func closeWindow(_ sender: Any?) { guard let window = window else { return } - guard let tabGroup = window.tabGroup else { - // No tabs, no tab group, just perform a normal close. - closeWindowImmediately() - return - } - // If have one window then we just do a normal close - if tabGroup.windows.count == 1 { - closeWindowImmediately() - return - } + // We need to check all the windows in our tab group for confirmation + // if we're closing the window. If we don't have a tabgroup for any + // reason we check ourselves. + let windows: [NSWindow] = window.tabGroup?.windows ?? [window] // Check if any windows require close confirmation. - let needsConfirm = tabGroup.windows.contains { tabWindow in + let needsConfirm = windows.contains { tabWindow in guard let controller = tabWindow.windowController as? TerminalController else { return false }