From e85a33ce15ba23d35d304f3193ddf8d24575f1f4 Mon Sep 17 00:00:00 2001 From: zonble Date: Tue, 15 Feb 2022 10:57:06 +0800 Subject: [PATCH] Fixes an Swift type conversion issue which happens while typing in Terminal app. Fixes #288. --- Source/InputMethodController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/InputMethodController.swift b/Source/InputMethodController.swift index 0e9b6f61..4208d23d 100644 --- a/Source/InputMethodController.swift +++ b/Source/InputMethodController.swift @@ -178,7 +178,7 @@ class McBopomofoInputMethodController: IMKInputController { let useVerticalMode = (attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false if (client as? IMKTextInput)?.bundleIdentifier() == "com.apple.Terminal" && - NSStringFromClass(client.self as! AnyClass) == "IPMDServerClientWrapper" { + String(describing: client.self) == "IPMDServerClientWrapper" { currentDeferredClient = client } @@ -312,7 +312,7 @@ extension McBopomofoInputMethodController { // if it's Terminal, we don't commit at the first call (the client of which will not be IPMDServerClientWrapper) // then we defer the update in the next runloop round -- so that the composing buffer is not // meaninglessly flushed, an annoying bug in Terminal.app since Mac OS X 10.5 - if (client as? IMKTextInput)?.bundleIdentifier() == "com.apple.Terminal" && NSStringFromClass(client.self as! AnyClass) != "IPMDServerClientWrapper" { + if (client as? IMKTextInput)?.bundleIdentifier() == "com.apple.Terminal" && String(describing: client.self) != "IPMDServerClientWrapper" { let innerCurrentDeferredClient = currentDeferredClient DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()) { (innerCurrentDeferredClient as? IMKTextInput)?.insertText(buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound))