Skip to content

Commit 980690c

Browse files
authored
don't set preedit on async commit (#235)
1 parent 99a9601 commit 980690c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

macosfrontend/macosfrontend.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ void MacosInputContext::commitStringImpl(const std::string &text) {
224224
// committed in next commit with a key event. e.g. fcitx commits a ,
225225
// asynchronously when deleting , after a number/English character.
226226
if (!isSyncEvent) {
227-
commitAndSetPreeditAsync();
227+
// When changing this, test Messages.app by clicking a candidate.
228+
// Previously buggy behavior is that preedit is appended after commit.
229+
SwiftFrontend::commitAsync(client_, state_.commit);
230+
resetState();
228231
}
229232
}
230233

macosfrontend/macosfrontend.swift

+10
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ public func commitAndSetPreeditAsync(
7070
}
7171
}
7272

73+
public func commitAsync(_ clientPtr: UnsafeMutableRawPointer, _ commit: String) {
74+
let client: AnyObject = Unmanaged.fromOpaque(clientPtr).takeUnretainedValue()
75+
guard let client = client as? IMKTextInput else {
76+
return
77+
}
78+
DispatchQueue.main.async {
79+
commitString(client, commit)
80+
}
81+
}
82+
7383
public func getCursorCoordinates(
7484
_ clientPtr: UnsafeMutableRawPointer,
7585
_ followCursor: Bool,

0 commit comments

Comments
 (0)