ctlIME // Make multi-char associates associable.

This commit is contained in:
ShikiSuen 2022-07-25 23:03:54 +08:00
parent 7c8b2062b8
commit 50cb3c7106
1 changed files with 10 additions and 3 deletions

View File

@ -120,6 +120,7 @@ extension ctlInputMethod: ctlCandidateDelegate {
keyHandler.clear()
let composingBuffer = inputting.composingBuffer
handle(state: InputState.Committing(textToCommit: composingBuffer))
// selectedValue.1
if mgrPrefs.associatedPhrasesEnabled,
let associatePhrases = keyHandler.buildAssociatePhraseState(
withPair: .init(key: selectedValue.0, value: selectedValue.1),
@ -139,16 +140,22 @@ extension ctlInputMethod: ctlCandidateDelegate {
if let state = state as? InputState.AssociatedPhrases {
let selectedValue = state.candidates[index]
handle(state: InputState.Committing(textToCommit: selectedValue.1))
// selectedValue.1
//
guard let valueKept = selectedValue.1.last else {
handle(state: InputState.Empty())
return
}
if mgrPrefs.associatedPhrasesEnabled,
let associatePhrases = keyHandler.buildAssociatePhraseState(
withPair: .init(key: selectedValue.0, value: selectedValue.1),
withPair: .init(key: selectedValue.0, value: String(valueKept)),
isTypingVertical: state.isTypingVertical
), !associatePhrases.candidates.isEmpty
{
handle(state: associatePhrases)
} else {
handle(state: InputState.Empty())
return
}
handle(state: InputState.Empty())
}
}
}