From 5b4394d211b9a4d4ce0460ff55a1a6345e2fe939 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Nov 2025 08:54:48 -0800 Subject: [PATCH] macos: end_search for ending search --- macos/Sources/Ghostty/SurfaceView_AppKit.swift | 4 ++-- src/Surface.zig | 9 ++++++++- src/config/Config.zig | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/macos/Sources/Ghostty/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/SurfaceView_AppKit.swift index 8aa108f3f..83e66ab81 100644 --- a/macos/Sources/Ghostty/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/SurfaceView_AppKit.swift @@ -93,7 +93,7 @@ extension Ghostty { } else if oldValue != nil { searchNeedleCancellable = nil guard let surface = self.surface else { return } - let action = "search:" + let action = "end_search" ghostty_surface_binding_action(surface, action, UInt(action.count)) } } @@ -1512,7 +1512,7 @@ extension Ghostty { @IBAction func findHide(_ sender: Any?) { guard let surface = self.surface else { return } - let action = "search:" + let action = "end_search" if (!ghostty_surface_binding_action(surface, action, UInt(action.count))) { AppDelegate.logger.warning("action failed action=\(action)") } diff --git a/src/Surface.zig b/src/Surface.zig index 698d1844b..d0866e901 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -4944,16 +4944,23 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool }, .end_search => { + // We only return that this was performed if we actually + // stopped a search, but we also send the apprt end_search so + // that GUIs can clean up stale stuff. + const performed = self.search != null; + if (self.search) |*s| { s.deinit(); self.search = null; } - return try self.rt_app.performAction( + _ = try self.rt_app.performAction( .{ .surface = self }, .end_search, {}, ); + + return performed; }, .search => |text| search: { diff --git a/src/config/Config.zig b/src/config/Config.zig index e6f7fb173..18412ff0e 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -6419,7 +6419,7 @@ pub const Keybinds = struct { try self.set.putFlags( alloc, .{ .key = .{ .physical = .escape } }, - .{ .search = "" }, + .end_search, .{ .performable = true }, ); try self.set.putFlags(