diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView.swift b/macos/Sources/Ghostty/Surface View/SurfaceView.swift index a0e735715..c5c2ee97c 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView.swift @@ -190,7 +190,12 @@ extension Ghostty { SurfaceSearchOverlay( surfaceView: surfaceView, searchState: searchState, - onClose: { surfaceView.searchState = nil } + onClose: { +#if canImport(AppKit) + Ghostty.moveFocus(to: surfaceView) +#endif + surfaceView.searchState = nil + } ) } @@ -432,7 +437,6 @@ extension Ghostty { #if canImport(AppKit) .onExitCommand { if searchState.needle.isEmpty { - Ghostty.moveFocus(to: surfaceView) onClose() } else { Ghostty.moveFocus(to: surfaceView)