macos: start_search refocuses the search input
parent
c61d28a3a4
commit
56d4a7f58e
|
|
@ -1662,8 +1662,12 @@ extension Ghostty {
|
||||||
|
|
||||||
let startSearch = Ghostty.Action.StartSearch(c: v)
|
let startSearch = Ghostty.Action.StartSearch(c: v)
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
if surfaceView.searchState != nil {
|
||||||
|
NotificationCenter.default.post(name: .ghosttySearchFocus, object: surfaceView)
|
||||||
|
} else {
|
||||||
surfaceView.searchState = Ghostty.SurfaceView.SearchState(from: startSearch)
|
surfaceView.searchState = Ghostty.SurfaceView.SearchState(from: startSearch)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assertionFailure()
|
assertionFailure()
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue