macOS: fix search bar Enter key blocking IME composition (#12781)

Closes https://github.com/ghostty-org/ghostty/discussions/12774

`.onKeyPress(.return)` unconditionally returns `.handled`, so when IME
is composing the return key never reaches the IME to confirm the
candidate. The search bar gets stuck.

The fix: use `.onSubmit` for the next-match navigation — it only fires
when there is no composing text. In `.onKeyPress` only intercept
shift+return (previous match), return `.ignored` otherwise.

Tested on macOS 26.5, Ghostty 1.3.1, built from source. Chinese Pinyin
input in the search bar works correctly after the fix.
pull/12787/head
Mitchell Hashimoto 2026-05-23 14:51:12 -07:00 committed by GitHub
commit d5d8cef4d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 3 deletions

View File

@ -417,6 +417,9 @@ extension Ghostty {
// to our synced needle. // to our synced needle.
searchState.readPasteboardNeedle() searchState.readPasteboardNeedle()
} }
.onSubmit {
_ = surfaceView.navigateSearchToNext()
}
#if canImport(AppKit) #if canImport(AppKit)
.onExitCommand { .onExitCommand {
if searchState.needle.isEmpty { if searchState.needle.isEmpty {
@ -429,10 +432,9 @@ extension Ghostty {
.backport.onKeyPress(.return) { modifiers in .backport.onKeyPress(.return) { modifiers in
if modifiers.contains(.shift) { if modifiers.contains(.shift) {
_ = surfaceView.navigateSearchToPrevious() _ = surfaceView.navigateSearchToPrevious()
} else { return .handled
_ = surfaceView.navigateSearchToNext()
} }
return .handled return .ignored
} }
Button(action: { Button(action: {