diff --git a/Source/Modules/IMEState.swift b/Source/Modules/IMEState.swift index 7af65184..0f96e025 100644 --- a/Source/Modules/IMEState.swift +++ b/Source/Modules/IMEState.swift @@ -196,7 +196,10 @@ public extension IMEState { func attributedString(for session: IMKInputController) -> NSAttributedString { switch type { case .ofMarking: return data.attributedStringMarking(for: session) - case .ofAssociates, .ofSymbolTable: return data.attributedStringPlaceholder(for: session) + case .ofAssociates: return data.attributedStringPlaceholder(for: session) + case .ofSymbolTable: + guard !displayedText.isEmpty else { return data.attributedStringPlaceholder(for: session) } + return data.attributedStringNormal(for: session) default: return data.attributedStringNormal(for: session) } } diff --git a/Source/Modules/SessionCtl_Delegates.swift b/Source/Modules/SessionCtl_Delegates.swift index c14e3b58..1669da46 100644 --- a/Source/Modules/SessionCtl_Delegates.swift +++ b/Source/Modules/SessionCtl_Delegates.swift @@ -125,7 +125,26 @@ extension SessionCtl: CtlCandidateDelegate { } public func candidatePairHighlightChanged(at theIndex: Int) { - inputHandler?.previewCompositionBufferForCandidate(at: theIndex) + guard let inputHandler = inputHandler else { return } + guard state.isCandidateContainer else { return } + switch state.type { + case .ofCandidates where (0 ..< state.candidates.count).contains(theIndex): + inputHandler.previewCompositionBufferForCandidate(at: theIndex) + case .ofSymbolTable where (0 ..< state.node.members.count).contains(theIndex): + let node = state.node.members[theIndex] + if node.members.isEmpty { + state.data.displayedText = node.name + state.data.cursor = node.name.count + } else { + state.data.displayedText.removeAll() + state.data.cursor = 0 + } + setInlineDisplayWithCursor() + if clientMitigationLevel >= 2, state.hasComposition { + updatePopupDisplayWithCursor() + } + default: break + } } public func candidatePairSelectionConfirmed(at index: Int) {