From 90d21a6a6544052007ed7dbdd081953ee4f6ef8b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 22 Aug 2024 19:58:21 -0700 Subject: [PATCH] macos: do not open a window on reopen if terminal manager has any Fixes #2135. See the comment on how this is possible. --- macos/Sources/App/macOS/AppDelegate.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 7618c4c72..603523e80 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -208,6 +208,12 @@ class AppDelegate: NSObject, // of focusing one of them. guard !flag else { return true } + // If we have any windows in our terminal manager we don't do anything. + // This is possible with flag set to false if there a race where the + // window is still initializing and is not visible but the user clicked + // the dock icon. + guard terminalManager.windows.count == 0 else { return true } + // No visible windows, open a new one. terminalManager.newWindow() return false