diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift index 7e76e3554..4fb156317 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift @@ -2042,6 +2042,8 @@ extension Ghostty.SurfaceView: NSTextInputClient { return } + let hadMarkedText = hasMarkedText() + // If insertText is called, our preedit must be over. unmarkText() @@ -2053,6 +2055,13 @@ extension Ghostty.SurfaceView: NSTextInputClient { return } + if hadMarkedText, !chars.isEmpty { + // Send preedit commits as key events instead of raw text for + // keybind interpretation by programs. + _ = committedPreeditTextAction(GHOSTTY_ACTION_PRESS, text: chars) + return + } + surfaceModel.sendText(chars) }