KeyHandler // Refactor handlePunctuation().

This commit is contained in:
ShikiSuen 2022-06-30 18:30:03 +08:00
parent df74b5b234
commit 00f44ffbcb
1 changed files with 28 additions and 27 deletions

View File

@ -295,14 +295,23 @@ extension KeyHandler {
return false
}
if composer.isEmpty {
guard composer.isEmpty else {
//
IME.prtDebugIntel("A9B69908D")
errorCallback()
stateCallback(state)
return true
}
insertToCompositorAtCursor(reading: customPunctuation)
let textToCommit = commitOverflownCompositionAndWalk
let inputting = buildInputtingState
inputting.textToCommit = textToCommit
stateCallback(inputting)
if mgrPrefs.useSCPCTypingMode, composer.isEmpty {
//
guard mgrPrefs.useSCPCTypingMode, composer.isEmpty else { return true }
let candidateState = buildCandidate(
state: inputting,
isTypingVertical: isTypingVertical
@ -310,7 +319,7 @@ extension KeyHandler {
if candidateState.candidates.count == 1 {
clear()
if let strtextToCommit: String = candidateState.candidates.first {
stateCallback(InputState.Committing(textToCommit: strtextToCommit) as InputState.Committing)
stateCallback(InputState.Committing(textToCommit: strtextToCommit))
stateCallback(InputState.Empty())
} else {
stateCallback(candidateState)
@ -318,15 +327,7 @@ extension KeyHandler {
} else {
stateCallback(candidateState)
}
}
return true
} else {
// If there is still unfinished bpmf reading, ignore the punctuation
IME.prtDebugIntel("A9B69908D")
errorCallback()
stateCallback(state)
return true
}
}
// MARK: - Enter