diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView.swift b/macos/Sources/Ghostty/Surface View/SurfaceView.swift index 524cb1298..a0e735715 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView.swift @@ -431,7 +431,12 @@ extension Ghostty { } #if canImport(AppKit) .onExitCommand { - Ghostty.moveFocus(to: surfaceView) + if searchState.needle.isEmpty { + Ghostty.moveFocus(to: surfaceView) + onClose() + } else { + Ghostty.moveFocus(to: surfaceView) + } } #endif .backport.onKeyPress(.return) { modifiers in