Skip to content

Commit fbac65c

Browse files
feat: commit composition on keyboard switch with ascii_mode change
1 parent cbcd477 commit fbac65c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardWindow.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ class KeyboardWindow(
131131
val targetMode = if (it.resetAsciiMode) it.asciiMode else it.lastAsciiMode
132132

133133
if (currentMode != targetMode) {
134-
service.postRimeJob { setRuntimeOption("ascii_mode", targetMode) }
134+
service.postRimeJob {
135+
commitComposition()
136+
setRuntimeOption("ascii_mode", targetMode)
137+
}
135138
}
136139

137140
// TODO:为避免过量重构,这里暂时将 currentKeyboard 同步到 KeyboardSwitcher

app/src/main/java/com/osfans/trime/ime/symbol/LiquidWindow.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ class LiquidWindow(
120120
val (isAsciiMode, isAsciiPunch) = it.statusCached.run { isAsciiMode to isAsciiPunct }
121121
if (isAsciiMode) it.setRuntimeOption("ascii_mode", false)
122122
if (isAsciiPunch) it.setRuntimeOption("ascii_punch", false)
123-
commonKeyboardActionListener.listener.onText("{Escape}$symbol")
123+
it.clearComposition()
124+
it.simulateKeySequence(symbol)
124125
if (isAsciiPunch) it.setRuntimeOption("ascii_punch", true)
125126
ContextCompat.getMainExecutor(service).execute {
126127
windowManager.attachWindow(KeyboardWindow)

0 commit comments

Comments
 (0)