From 76ae039701a02ceb7f8f0e99db917e083aa0c9c9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 2 Sep 2023 16:37:22 -0700 Subject: [PATCH] macos: new split on zoomed split unzooms --- macos/Sources/Ghostty/Ghostty.SplitView.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/macos/Sources/Ghostty/Ghostty.SplitView.swift b/macos/Sources/Ghostty/Ghostty.SplitView.swift index 924b24603..e8ee1bb78 100644 --- a/macos/Sources/Ghostty/Ghostty.SplitView.swift +++ b/macos/Sources/Ghostty/Ghostty.SplitView.swift @@ -248,8 +248,12 @@ extension Ghostty { } .navigationTitle(surfaceTitle ?? "Ghostty") } else { + // On split, we want to reset the zoom state. + let pubSplit = center.publisher(for: Notification.ghosttyNewSplit, object: zoomedSurface!) + ZStack {} .onReceive(pubZoom) { onZoomReset(notification: $0) } + .onReceive(pubSplit) { onZoomReset(notification: $0) } } } @@ -281,7 +285,19 @@ extension Ghostty { // We need to stay focused on this view, but the view is going to change // superviews. We need to do this async so it happens on the next event loop // tick. - DispatchQueue.main.async { Ghostty.moveFocus(to: surfaceView) } + DispatchQueue.main.async { + Ghostty.moveFocus(to: surfaceView) + + // If the notification is a new split notification, we want to re-publish + // it after a short delay so that the split tree has a chance to re-establish + // so the proper view gets this notification. + if (notification.name == Notification.ghosttyNewSplit) { + // We have to wait ANOTHER tick since we just established. + DispatchQueue.main.async { + NotificationCenter.default.post(notification) + } + } + } } }