From 99275a468291d225504f672f62e0fd2d69076915 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 9 Feb 2023 16:42:21 +0800 Subject: [PATCH] SessionCtl // Again clearInlineDisplay() on deactivation. * Also optimize doSetMarkedText(). --- Source/Modules/SessionCtl_HandleStates.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Modules/SessionCtl_HandleStates.swift b/Source/Modules/SessionCtl_HandleStates.swift index 5fb7f550..2f977bb8 100644 --- a/Source/Modules/SessionCtl_HandleStates.swift +++ b/Source/Modules/SessionCtl_HandleStates.swift @@ -48,6 +48,10 @@ public extension SessionCtl { candidateUI?.visible = false popupCompositionBuffer.hide() tooltipInstance.hide() + inputHandler?.clear() + if ![.ofAbortion, .ofEmpty].contains(previous.type), !previous.displayedText.isEmpty { + clearInlineDisplay() + } case .ofEmpty, .ofAbortion, .ofCommitting: innerCircle: switch newState.type { case .ofAbortion: @@ -137,12 +141,13 @@ public extension SessionCtl { /// 把 setMarkedText 包裝一下,按需啟用 GCD。 func doSetMarkedText(_ string: Any!, selectionRange: NSRange, replacementRange: NSRange) { - guard isActivated, let client = client() else { return } - if isServingIMEItself { + if isServingIMEItself || !isActivated { DispatchQueue.main.async { + guard let client = self.client() else { return } client.setMarkedText(string, selectionRange: selectionRange, replacementRange: replacementRange) } } else { + guard let client = client() else { return } client.setMarkedText(string, selectionRange: selectionRange, replacementRange: replacementRange) } }