From ba0e47ad613e7e3c3cf545531d6e87e01ef6c967 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sat, 10 Sep 2022 19:07:33 +0800 Subject: [PATCH] ctlIME // Fix wrong calculation of utf16Cursors with lineHeightRect. --- .../ControllerModules/ctlInputMethod_HandleDisplay.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/ControllerModules/ctlInputMethod_HandleDisplay.swift b/Source/Modules/ControllerModules/ctlInputMethod_HandleDisplay.swift index 3f50bba0..a969cc21 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_HandleDisplay.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_HandleDisplay.swift @@ -17,7 +17,7 @@ extension ctlInputMethod { guard let client = client() else { return } var lineHeightRect = NSRect(x: 0.0, y: 0.0, width: 16.0, height: 16.0) var cursor = u16Cursor - if cursor == displayedText.count, cursor != 0 { + if cursor == displayedText.utf16.count, cursor != 0 { cursor -= 1 } while lineHeightRect.origin.x == 0, lineHeightRect.origin.y == 0, cursor >= 0 { @@ -124,8 +124,8 @@ extension ctlInputMethod { var cursor = 0 if [.ofCandidates, .ofSymbolTable].contains(state.type) { - cursor = state.data.cursor - if cursor == state.displayedText.count, cursor != 0 { + cursor = state.data.u16Cursor + if cursor == state.displayedText.utf16.count, cursor != 0 { cursor -= 1 } }