SessionCtl // Optimize handlings of Committing() state.

This commit is contained in:
ShikiSuen 2022-10-14 14:57:16 +08:00
parent 70e0044179
commit 2cf53d5c6a
1 changed files with 10 additions and 12 deletions

View File

@ -61,15 +61,20 @@ extension SessionCtl {
}
}
}
case .ofEmpty, .ofAbortion:
if newState.type == .ofAbortion {
previous = IMEState.ofEmpty()
if replace { state = previous }
case .ofEmpty, .ofAbortion, .ofCommitting:
innerCircle: switch newState.type {
case .ofAbortion:
previous = IMEState.ofEmpty()
if replace { state = previous }
case .ofCommitting:
commit(text: newState.textToCommit)
state = IMEState.ofEmpty()
default: break innerCircle
}
ctlCandidateCurrent.visible = false
tooltipInstance.hide()
// .Abortion
if previous.hasComposition, newState.type != .ofAbortion {
if previous.hasComposition, ![.ofAbortion, .ofCommitting].contains(newState.type) {
commit(text: previous.displayedText)
}
//
@ -77,13 +82,6 @@ extension SessionCtl {
clearInlineDisplay()
//
inputHandler.clear()
case .ofCommitting:
ctlCandidateCurrent.visible = false
tooltipInstance.hide()
commit(text: newState.textToCommit)
clearInlineDisplay()
//
inputHandler.clear()
case .ofInputting:
ctlCandidateCurrent.visible = false
tooltipInstance.hide()