diff --git a/Sources/GhosttyTerminalView.swift b/Sources/GhosttyTerminalView.swift index fa45477c..ed1cb0ea 100644 --- a/Sources/GhosttyTerminalView.swift +++ b/Sources/GhosttyTerminalView.swift @@ -8573,13 +8573,17 @@ struct GhosttyTerminalView: NSViewRepresentable { return !hostedViewHasSuperview } - private static func scheduleDeferredPortalGeometrySynchronize( + private static func synchronizePortalGeometry( for host: HostContainerView, coordinator: Coordinator ) { let geometryRevision = host.geometryRevision guard coordinator.lastSynchronizedHostGeometryRevision != geometryRevision else { return } coordinator.lastSynchronizedHostGeometryRevision = geometryRevision + if host.inLiveResize || host.window?.inLiveResize == true { + TerminalWindowPortalRegistry.synchronizeForAnchor(host) + return + } // Avoid synchronizing the terminal portal while AppKit is still inside // the current layout turn. Re-entrant syncs here can wedge window resize // handling and leave the app spinning on the wait cursor. @@ -8745,7 +8749,7 @@ struct GhosttyTerminalView: NSViewRepresentable { hostedView.setActive(coordinator.desiredIsActive) hostedView.setNotificationRing(visible: coordinator.desiredShowsUnreadNotificationRing) } - Self.scheduleDeferredPortalGeometrySynchronize( + Self.synchronizePortalGeometry( for: host, coordinator: coordinator ) @@ -8783,7 +8787,7 @@ struct GhosttyTerminalView: NSViewRepresentable { coordinator.lastBoundHostId = hostId coordinator.lastSynchronizedHostGeometryRevision = geometryRevision } else if coordinator.lastSynchronizedHostGeometryRevision != geometryRevision { - Self.scheduleDeferredPortalGeometrySynchronize( + Self.synchronizePortalGeometry( for: host, coordinator: coordinator ) diff --git a/Sources/TerminalWindowPortal.swift b/Sources/TerminalWindowPortal.swift index fd15c702..e4b78917 100644 --- a/Sources/TerminalWindowPortal.swift +++ b/Sources/TerminalWindowPortal.swift @@ -680,12 +680,18 @@ final class WindowTerminalPortal: NSObject { private func scheduleExternalGeometrySynchronize() { guard !hasExternalGeometrySyncScheduled else { return } hasExternalGeometrySyncScheduled = true + let requiresSettledLayout = !(hostView.inLiveResize || window?.inLiveResize == true) DispatchQueue.main.async { [weak self] in guard let self else { return } - DispatchQueue.main.async { + let performSync = { self.hasExternalGeometrySyncScheduled = false self.synchronizeAllEntriesFromExternalGeometryChange() } + if requiresSettledLayout { + DispatchQueue.main.async(execute: performSync) + } else { + performSync() + } } }