Fixes an Swift type conversion issue which happens while typing in Terminal app.

Fixes #288.
This commit is contained in:
zonble 2022-02-15 10:57:06 +08:00
parent 39a9330969
commit e85a33ce15
1 changed files with 2 additions and 2 deletions

View File

@ -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))