macos: start_search refocuses the search input

pull/9709/head
Mitchell Hashimoto 2025-11-25 12:24:04 -08:00
parent c61d28a3a4
commit 56d4a7f58e
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
3 changed files with 12 additions and 1 deletions

View File

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

View File

@ -396,6 +396,9 @@ extension Notification.Name {
/// Notification sent when scrollbar updates /// Notification sent when scrollbar updates
static let ghosttyDidUpdateScrollbar = Notification.Name("com.mitchellh.ghostty.didUpdateScrollbar") static let ghosttyDidUpdateScrollbar = Notification.Name("com.mitchellh.ghostty.didUpdateScrollbar")
static let ScrollbarKey = ghosttyDidUpdateScrollbar.rawValue + ".scrollbar" static let ScrollbarKey = ghosttyDidUpdateScrollbar.rawValue + ".scrollbar"
/// Focus the search field
static let ghosttySearchFocus = Notification.Name("com.mitchellh.ghostty.searchFocus")
} }
// NOTE: I am moving all of these to Notification.Name extensions over time. This // NOTE: I am moving all of these to Notification.Name extensions over time. This

View File

@ -441,6 +441,10 @@ extension Ghostty {
} }
isSearchFieldFocused = true isSearchFieldFocused = true
} }
.onReceive(NotificationCenter.default.publisher(for: .ghosttySearchFocus)) { notification in
guard notification.object as? SurfaceView === surfaceView else { return }
isSearchFieldFocused = true
}
.background( .background(
GeometryReader { barGeo in GeometryReader { barGeo in
Color.clear.onAppear { Color.clear.onAppear {