@@ -12,6 +12,7 @@ import org.fcitx.fcitx5.android.core.KeyState
12
12
import org.fcitx.fcitx5.android.daemon.launchOnReady
13
13
import org.fcitx.fcitx5.android.data.prefs.AppPrefs
14
14
import org.fcitx.fcitx5.android.input.broadcast.PreeditEmptyStateComponent
15
+ import org.fcitx.fcitx5.android.input.candidates.HorizontalCandidateComponent
15
16
import org.fcitx.fcitx5.android.input.dependency.context
16
17
import org.fcitx.fcitx5.android.input.dependency.fcitx
17
18
import org.fcitx.fcitx5.android.input.dependency.inputMethodService
@@ -52,6 +53,7 @@ class CommonKeyActionListener :
52
53
private val service by manager.inputMethodService()
53
54
private val inputView by manager.inputView()
54
55
private val preeditState: PreeditEmptyStateComponent by manager.must()
56
+ private val horizontalCandidate: HorizontalCandidateComponent by manager.must()
55
57
private val windowManager: InputWindowManager by manager.must()
56
58
57
59
private var lastPickerType by AppPrefs .getInstance().internal.lastPickerType
@@ -63,11 +65,13 @@ class CommonKeyActionListener :
63
65
64
66
private var backspaceSwipeState = Stopped
65
67
68
+ private val keepComposingIMs = arrayOf(" keyboard-us" , " unikey" )
69
+
66
70
private suspend fun FcitxAPI.commitAndReset () {
67
71
if (clientPreeditCached.isEmpty() && inputPanelCached.preedit.isEmpty()) {
68
72
// preedit is empty, there can be prediction candidates
69
73
reset()
70
- } else if (inputMethodEntryCached.uniqueName. let { it == " keyboard-us " || it == " unikey " } ) {
74
+ } else if (inputMethodEntryCached.uniqueName in keepComposingIMs ) {
71
75
// androidkeyboard clears composing on reset, but we want to commit it as-is
72
76
service.finishComposing()
73
77
reset()
@@ -132,7 +136,10 @@ class CommonKeyActionListener :
132
136
is MoveSelectionAction -> {
133
137
when (backspaceSwipeState) {
134
138
Stopped -> {
135
- backspaceSwipeState = if (preeditState.isEmpty) {
139
+ backspaceSwipeState = if (
140
+ preeditState.isEmpty &&
141
+ horizontalCandidate.adapter.total == 0
142
+ ) {
136
143
service.applySelectionOffset(action.start, action.end)
137
144
Selection
138
145
} else {
0 commit comments