ctlIME // Fix wrong calculation of utf16Cursors with lineHeightRect.

This commit is contained in:
ShikiSuen 2022-09-10 19:07:33 +08:00
parent a2f0b94879
commit ba0e47ad61
1 changed files with 3 additions and 3 deletions

View File

@ -17,7 +17,7 @@ extension ctlInputMethod {
guard let client = client() else { return } guard let client = client() else { return }
var lineHeightRect = NSRect(x: 0.0, y: 0.0, width: 16.0, height: 16.0) var lineHeightRect = NSRect(x: 0.0, y: 0.0, width: 16.0, height: 16.0)
var cursor = u16Cursor var cursor = u16Cursor
if cursor == displayedText.count, cursor != 0 { if cursor == displayedText.utf16.count, cursor != 0 {
cursor -= 1 cursor -= 1
} }
while lineHeightRect.origin.x == 0, lineHeightRect.origin.y == 0, cursor >= 0 { while lineHeightRect.origin.x == 0, lineHeightRect.origin.y == 0, cursor >= 0 {
@ -124,8 +124,8 @@ extension ctlInputMethod {
var cursor = 0 var cursor = 0
if [.ofCandidates, .ofSymbolTable].contains(state.type) { if [.ofCandidates, .ofSymbolTable].contains(state.type) {
cursor = state.data.cursor cursor = state.data.u16Cursor
if cursor == state.displayedText.count, cursor != 0 { if cursor == state.displayedText.utf16.count, cursor != 0 {
cursor -= 1 cursor -= 1
} }
} }