From 9bfd58f28e04d22f20cee6a9d25b2789a637b483 Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Thu, 4 Jul 2024 14:36:16 -0400 Subject: [PATCH] fix using Shift to select results in clearing selected text (#168) --- macosfrontend/macosfrontend.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/macosfrontend/macosfrontend.swift b/macosfrontend/macosfrontend.swift index aa6368b..4aa8280 100644 --- a/macosfrontend/macosfrontend.swift +++ b/macosfrontend/macosfrontend.swift @@ -38,7 +38,10 @@ public func commitAndSetPreeditSync( // Without client preedit, Backspace bypasses IM in Terminal, every key // is both processed by IM and passed to client in iTerm, so we force a // dummy client preedit here. - if preedit.isEmpty && dummyPreedit { + // Some apps also need it to get accurate cursor position to place candidate window. + // But when there is selected text, we don't want the dummy preedit to clear all of + // them. An example is using Shift+click to select but IM switch happens. + if preedit.isEmpty && dummyPreedit && client.selectedRange().length == 0 { setPreedit(client, " ", 0) } else { setPreedit(client, preedit, cursorPos)