From 751a60df61526ab71e32838f321ada374b3c1a43 Mon Sep 17 00:00:00 2001 From: qappell <164906821+qappell@users.noreply.github.com> Date: Tue, 7 Jul 2026 13:00:39 -0500 Subject: [PATCH] macos: route IME preedit commits through key events --- .../Ghostty/Surface View/SurfaceView_AppKit.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift index 272f16e5a..5c497344f 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) }