diff --git a/Source/Modules/ControllerModules/InputState.swift b/Source/Modules/ControllerModules/InputState.swift index b7a64d69..8deea7e1 100644 --- a/Source/Modules/ControllerModules/InputState.swift +++ b/Source/Modules/ControllerModules/InputState.swift @@ -146,6 +146,17 @@ enum InputState { self.isTypingVertical = isTypingVertical } + var attributedString: NSMutableAttributedString { + let attributedString = NSMutableAttributedString( + string: " ", + attributes: [ + .underlineStyle: NSUnderlineStyle.single.rawValue, + .markedClauseSegment: 0, + ] + ) + return attributedString + } + var description: String { "" } diff --git a/Source/Modules/ControllerModules/ctlInputMethod_HandleStates.swift b/Source/Modules/ControllerModules/ctlInputMethod_HandleStates.swift index 0c5f78a4..2e37e696 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_HandleStates.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_HandleStates.swift @@ -63,6 +63,14 @@ extension ctlInputMethod { /// 針對受 .NotEmpty() 管轄的非空狀態,在組字區內顯示游標。 private func setInlineDisplayWithCursor() { + if let state = state as? InputState.AssociatedPhrases { + client().setMarkedText( + state.attributedString, selectionRange: NSRange(location: 0, length: 0), + replacementRange: NSRange(location: NSNotFound, length: NSNotFound) + ) + return + } + guard let state = state as? InputState.NotEmpty else { clearInlineDisplay() return @@ -225,7 +233,7 @@ extension ctlInputMethod { private func handle(state: InputState.AssociatedPhrases, previous: InputStateProtocol) { _ = previous // 防止格式整理工具毀掉與此對應的參數。 ctlInputMethod.tooltipController.hide() - clearInlineDisplay() + setInlineDisplayWithCursor() show(candidateWindowWith: state) } }