macos: start_search with needle changes needle

This commit is contained in:
Mitchell Hashimoto
2026-01-06 14:12:26 -08:00
parent 8e28f58b42
commit f07d600e43
2 changed files with 9 additions and 3 deletions

View File

@@ -1869,11 +1869,15 @@ extension Ghostty {
let startSearch = Ghostty.Action.StartSearch(c: v)
DispatchQueue.main.async {
if surfaceView.searchState != nil {
NotificationCenter.default.post(name: .ghosttySearchFocus, object: surfaceView)
if let searchState = surfaceView.searchState {
if let needle = startSearch.needle, !needle.isEmpty {
searchState.needle = needle
}
} else {
surfaceView.searchState = Ghostty.SurfaceView.SearchState(from: startSearch)
}
NotificationCenter.default.post(name: .ghosttySearchFocus, object: surfaceView)
}
default:

View File

@@ -313,7 +313,9 @@ pub const Action = union(Key) {
/// A command has finished,
command_finished: CommandFinished,
/// Start the search overlay with an optional initial needle.
/// Start the search overlay with an optional initial needle. If the
/// search is already active and the needle is non-empty, update the
/// current search needle and focus the search input.
start_search: StartSearch,
/// End the search overlay, clearing the search state and hiding it.