Skip to content

Commit e60b1c2

Browse files
committed
fix preedit in SwiftUI TextField with pinyin prediction
1 parent 33d7821 commit e60b1c2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

macosfrontend/macosfrontend.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public func setStatusItemMode(_ mode: Int32) {
3030

3131
private func commitString(_ client: IMKTextInput, _ string: String) {
3232
client.insertText(string, replacementRange: NSRange(location: NSNotFound, length: NSNotFound))
33+
// Without it currentPreedit.count in commitAndSetPreeditSync will be wrong with pinyin prediction.
34+
currentPreedit = ""
3335
}
3436

3537
private func setPreedit(_ client: IMKTextInput, _ preedit: String, _ caretPosUtf8: Int) {

0 commit comments

Comments
 (0)