mirror of
https://github.com/fcitx5-android/fcitx5-android.git
synced 2026-08-02 04:44:35 +08:00
Tweak commitAndReset workaround for all languages
Chinese: select 1st candidate (excluding prediction) and reset Others: commit preedit as-is and reset
This commit is contained in:
parent
28df3f2a80
commit
1aabfbe75f
@ -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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user