macOS tip regression: Confirm close on window close (#7617)

Fixes #7615

We were incorrectly closing the window without confirmation when there
were no tabs.

This was part of the undo/redo PR.
pull/7619/head
Mitchell Hashimoto 2025-06-17 15:20:53 -07:00 committed by GitHub
commit 7d01332574
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 11 deletions

View File

@ -1001,20 +1001,14 @@ class TerminalController: BaseTerminalController {
@IBAction override func closeWindow(_ sender: Any?) { @IBAction override func closeWindow(_ sender: Any?) {
guard let window = window else { return } 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 // We need to check all the windows in our tab group for confirmation
if tabGroup.windows.count == 1 { // if we're closing the window. If we don't have a tabgroup for any
closeWindowImmediately() // reason we check ourselves.
return let windows: [NSWindow] = window.tabGroup?.windows ?? [window]
}
// Check if any windows require close confirmation. // 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 { guard let controller = tabWindow.windowController as? TerminalController else {
return false return false
} }