Skip to content

Commit 33d7821

Browse files
committed
fix Swift runtime failure: arithmetic overflow
1 parent 9357f45 commit 33d7821

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

macosfrontend/macosfrontend.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ public func commitAndSetPreeditSync(
8181
// For SwiftUI TextField, there is a bug that if caret is at the end of text, zero-width space preedit
8282
// spreads from the start to the end, making the whole text underlined. Fortunately, SwiftUI's length
8383
// and selectedRange are reliable, so we use a normal space in this case.
84-
if length > 0 && length - currentPreedit.count == selectedRange.location + selectedRange.length
85-
{
84+
if length > 0 && length - currentPreedit.count == NSMaxRange(selectedRange) {
8685
setPreedit(client, " ", 0)
8786
} else {
8887
setPreedit(client, zeroWidthSpace, 0)

0 commit comments

Comments
 (0)