SessionCtl // Optimize commit().
This commit is contained in:
parent
99275a4682
commit
ba164520fc
|
@ -121,18 +121,16 @@ public extension SessionCtl {
|
||||||
/// 注意:必須在 IMK 的 commitComposition 函式當中也間接或者直接執行這個處理。
|
/// 注意:必須在 IMK 的 commitComposition 函式當中也間接或者直接執行這個處理。
|
||||||
private func commit(text: String) {
|
private func commit(text: String) {
|
||||||
let text = text.trimmingCharacters(in: .newlines)
|
let text = text.trimmingCharacters(in: .newlines)
|
||||||
guard let client = client(), !text.isEmpty else { return }
|
|
||||||
let buffer = ChineseConverter.kanjiConversionIfRequired(text)
|
let buffer = ChineseConverter.kanjiConversionIfRequired(text)
|
||||||
if buffer.isEmpty {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if isServingIMEItself {
|
if isServingIMEItself {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
guard let client = self.client() else { return }
|
||||||
client.insertText(
|
client.insertText(
|
||||||
buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound)
|
buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
guard let client = client() else { return }
|
||||||
client.insertText(
|
client.insertText(
|
||||||
buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound)
|
buffer, replacementRange: NSRange(location: NSNotFound, length: NSNotFound)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue