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