From be7be538af91e7e011c28e21d939b01b24ea12bd Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Sat, 18 Nov 2023 08:40:40 -0600 Subject: [PATCH] macos: ensure all surfaces are closed when a window is closed --- macos/Sources/Features/Terminal/TerminalController.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 61853fa71..517b4becb 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -19,9 +19,12 @@ class TerminalController: NSWindowController, NSWindowDelegate, /// The surface tree for this window. @Published var surfaceTree: Ghostty.SplitNode? = nil { didSet { - // If our surface tree becomes nil then it means all our surfaces - // have closed, so we also close the window. - if (surfaceTree == nil) { lastSurfaceDidClose() } + // If our surface tree becomes nil then ensure all surfaces + // in the old tree have closed and then close the window. + if (surfaceTree == nil) { + oldValue?.close() + lastSurfaceDidClose() + } } }