From 1aabfbe75fb5a30937d03086be2f6c24cf811e46 Mon Sep 17 00:00:00 2001 From: Rocka Date: Wed, 13 Aug 2025 00:12:34 +0800 Subject: [PATCH] Tweak commitAndReset workaround for all languages Chinese: select 1st candidate (excluding prediction) and reset Others: commit preedit as-is and reset --- .../input/keyboard/CommonKeyActionListener.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/CommonKeyActionListener.kt b/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/CommonKeyActionListener.kt index a4a8bb9d..3847b97f 100644 --- a/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/CommonKeyActionListener.kt +++ b/app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/CommonKeyActionListener.kt @@ -64,19 +64,19 @@ class CommonKeyActionListener : private var backspaceSwipeState = Stopped - private val keepComposingIMs = arrayOf("keyboard-us", "unikey") - + // there should be a new fcitx API for this private suspend fun FcitxAPI.commitAndReset() { - if (clientPreeditCached.isEmpty() && inputPanelCached.preedit.isEmpty()) { - // preedit is empty, there can be prediction candidates - reset() - } else if (inputMethodEntryCached.uniqueName in keepComposingIMs) { - // androidkeyboard clears composing on reset, but we want to commit it as-is - service.finishComposing() - reset() + if (inputMethodEntryCached.languageCode.startsWith("zh")) { + // Chinese: select 1st candidate, except prediction candidates + if (clientPreeditCached.isNotEmpty() || inputPanelCached.preedit.isNotEmpty()) { + // preedit not empty, maybe there are candidates to select ... + select(0) + } } else { - if (!select(0)) reset() + // Other languages: commit preedit as-is + service.finishComposing() } + reset() } private fun showInputMethodPicker() {