Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class CjkInputManager private constructor(private val context: Context) {

private var uiListener: CjkUiListener? = null
private var activeLocale: String? = null
// Engine instance that activeLocale was applied to; a reloaded engine starts from its default locale
private var localeEngine: ICjkEngine? = null
var isComposing: Boolean = false
internal set

Expand Down Expand Up @@ -59,9 +61,10 @@ class CjkInputManager private constructor(private val context: Context) {
}

val lang = subtype?.locale?.language?.lowercase() ?: "zh"
if (activeLocale != lang) {
if (activeLocale != lang || localeEngine !== engine) {
engine.setLocale(lang)
activeLocale = lang
localeEngine = engine
}

val keysym = KeycodeTranslator.toKeysym(event)
Expand Down Expand Up @@ -186,6 +189,8 @@ class CjkInputManager private constructor(private val context: Context) {
}
uiListener?.onSetCandidateStripVisibility(false)
CjkPluginLoader.getEngine(context)?.destroySession()
// destroySession may reset the engine to its default locale (zh), so force setLocale on the next key
activeLocale = null
}

companion object {
Expand Down
Loading