Skip to content

Commit c638e40

Browse files
committed
Swipe left backspace key to clear predict candidates
1 parent 742c95f commit c638e40

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/src/main/java/org/fcitx/fcitx5/android/input/keyboard/CommonKeyActionListener.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.fcitx.fcitx5.android.core.KeyState
1212
import org.fcitx.fcitx5.android.daemon.launchOnReady
1313
import org.fcitx.fcitx5.android.data.prefs.AppPrefs
1414
import org.fcitx.fcitx5.android.input.broadcast.PreeditEmptyStateComponent
15+
import org.fcitx.fcitx5.android.input.candidates.HorizontalCandidateComponent
1516
import org.fcitx.fcitx5.android.input.dependency.context
1617
import org.fcitx.fcitx5.android.input.dependency.fcitx
1718
import org.fcitx.fcitx5.android.input.dependency.inputMethodService
@@ -52,6 +53,7 @@ class CommonKeyActionListener :
5253
private val service by manager.inputMethodService()
5354
private val inputView by manager.inputView()
5455
private val preeditState: PreeditEmptyStateComponent by manager.must()
56+
private val horizontalCandidate: HorizontalCandidateComponent by manager.must()
5557
private val windowManager: InputWindowManager by manager.must()
5658

5759
private var lastPickerType by AppPrefs.getInstance().internal.lastPickerType
@@ -63,11 +65,13 @@ class CommonKeyActionListener :
6365

6466
private var backspaceSwipeState = Stopped
6567

68+
private val keepComposingIMs = arrayOf("keyboard-us", "unikey")
69+
6670
private suspend fun FcitxAPI.commitAndReset() {
6771
if (clientPreeditCached.isEmpty() && inputPanelCached.preedit.isEmpty()) {
6872
// preedit is empty, there can be prediction candidates
6973
reset()
70-
} else if (inputMethodEntryCached.uniqueName.let { it == "keyboard-us" || it == "unikey" }) {
74+
} else if (inputMethodEntryCached.uniqueName in keepComposingIMs) {
7175
// androidkeyboard clears composing on reset, but we want to commit it as-is
7276
service.finishComposing()
7377
reset()
@@ -132,7 +136,10 @@ class CommonKeyActionListener :
132136
is MoveSelectionAction -> {
133137
when (backspaceSwipeState) {
134138
Stopped -> {
135-
backspaceSwipeState = if (preeditState.isEmpty) {
139+
backspaceSwipeState = if (
140+
preeditState.isEmpty &&
141+
horizontalCandidate.adapter.total == 0
142+
) {
136143
service.applySelectionOffset(action.start, action.end)
137144
Selection
138145
} else {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy