From ba164520fcc3200227c774ac3e58f5e7350659c6 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 9 Feb 2023 16:42:32 +0800 Subject: [PATCH] SessionCtl // Optimize commit(). --- Source/Modules/SessionCtl_HandleStates.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/Modules/SessionCtl_HandleStates.swift b/Source/Modules/SessionCtl_HandleStates.swift index 2f977bb8..c0bf9eb3 100644 --- a/Source/Modules/SessionCtl_HandleStates.swift +++ b/Source/Modules/SessionCtl_HandleStates.swift @@ -121,18 +121,16 @@ public extension SessionCtl { /// 注意:必須在 IMK 的 commitComposition 函式當中也間接或者直接執行這個處理。 private func commit(text: String) { let text = text.trimmingCharacters(in: .newlines) - guard let client = client(), !text.isEmpty else { return } let buffer = ChineseConverter.kanjiConversionIfRequired(text) - if buffer.isEmpty { - return - } if isServingIMEItself { DispatchQueue.main.async { + guard let client = self.client() else { return } client.insertText( buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound) ) } } else { + guard let client = client() else { return } client.insertText( buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound) )