From f9f06728e86d60160bfbcdf4ce969814b6715892 Mon Sep 17 00:00:00 2001 From: Alexandre Antonio Juca Date: Thu, 16 Jan 2025 23:14:22 +0100 Subject: [PATCH] fix: focus lost when closing tab when using stage manager on macOS --- .../Features/Terminal/BaseTerminalController.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/macos/Sources/Features/Terminal/BaseTerminalController.swift b/macos/Sources/Features/Terminal/BaseTerminalController.swift index bda6d62bf5..8e35459da4 100644 --- a/macos/Sources/Features/Terminal/BaseTerminalController.swift +++ b/macos/Sources/Features/Terminal/BaseTerminalController.swift @@ -452,7 +452,16 @@ class BaseTerminalController: NSWindowController, self.alert = nil switch (response) { case .alertFirstButtonReturn: + if let windows = window.tabGroup?.windows, windows.count > 1 { + let secondLastWindow = windows[windows.count - 2] + secondLastWindow.makeKeyAndOrderFront(nil) + secondLastWindow.makeFirstResponder(nil) + + window.close() + } + window.close() + default: break