mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-05-24 05:40:15 +00:00
macOS: fix keybindings for end_search not working correctly (#12492)
This now fixes #11410 completely, `navigate_search:next` and
`navigate_search:previous` are already fixed in
18f2702225.
Also fixes: surface is not focused after ending search via menu bar
This commit is contained in:
@@ -1170,6 +1170,7 @@ extension AppDelegate {
|
||||
syncMenuShortcut(config, action: "paste_from_selection", menuItem: self.menuPasteSelection)
|
||||
syncMenuShortcut(config, action: "select_all", menuItem: self.menuSelectAll)
|
||||
syncMenuShortcut(config, action: "start_search", menuItem: self.menuFind)
|
||||
syncMenuShortcut(config, action: "end_search", menuItem: self.menuHideFindBar)
|
||||
syncMenuShortcut(config, action: "search_selection", menuItem: self.menuSelectionForFind)
|
||||
syncMenuShortcut(config, action: "scroll_to_selection", menuItem: self.menuScrollToSelection)
|
||||
syncMenuShortcut(config, action: "navigate_search:next", menuItem: self.menuFindNext)
|
||||
|
||||
@@ -645,7 +645,7 @@ extension Ghostty {
|
||||
startSearch(app, target: target, v: action.action.start_search)
|
||||
|
||||
case GHOSTTY_ACTION_END_SEARCH:
|
||||
endSearch(app, target: target)
|
||||
return endSearch(app, target: target)
|
||||
|
||||
case GHOSTTY_ACTION_SEARCH_TOTAL:
|
||||
searchTotal(app, target: target, v: action.action.search_total)
|
||||
@@ -2078,22 +2078,23 @@ extension Ghostty {
|
||||
|
||||
private static func endSearch(
|
||||
_ app: ghostty_app_t,
|
||||
target: ghostty_target_s) {
|
||||
target: ghostty_target_s) -> Bool {
|
||||
switch target.tag {
|
||||
case GHOSTTY_TARGET_APP:
|
||||
Ghostty.logger.warning("end_search does nothing with an app target")
|
||||
return
|
||||
return false
|
||||
|
||||
case GHOSTTY_TARGET_SURFACE:
|
||||
guard let surface = target.target.surface else { return }
|
||||
guard let surfaceView = self.surfaceView(from: surface) else { return }
|
||||
guard let surface = target.target.surface else { return false }
|
||||
guard let surfaceView = self.surfaceView(from: surface) else { return false }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
surfaceView.searchState = nil
|
||||
surfaceView.endSearch()
|
||||
}
|
||||
|
||||
return true
|
||||
default:
|
||||
assertionFailure()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,11 @@ extension Ghostty {
|
||||
self.childExitedMessage = message
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func endSearch() {
|
||||
searchState = nil
|
||||
}
|
||||
|
||||
// MARK: - Placeholders
|
||||
|
||||
func focusDidChange(_ focused: Bool) {}
|
||||
|
||||
@@ -164,10 +164,7 @@ extension Ghostty {
|
||||
surfaceView: surfaceView,
|
||||
searchState: searchState,
|
||||
onClose: {
|
||||
#if canImport(AppKit)
|
||||
Ghostty.moveFocus(to: surfaceView)
|
||||
#endif
|
||||
surfaceView.searchState = nil
|
||||
surfaceView.endSearch()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -389,6 +389,11 @@ extension Ghostty {
|
||||
progressReportTimer?.invalidate()
|
||||
}
|
||||
|
||||
override func endSearch() {
|
||||
Ghostty.moveFocus(to: self)
|
||||
super.endSearch()
|
||||
}
|
||||
|
||||
override func focusDidChange(_ focused: Bool) {
|
||||
guard let surface = self.surface else { return }
|
||||
guard self.focused != focused else { return }
|
||||
|
||||
Reference in New Issue
Block a user