From d4173bd9318778e5906a9e8afb2e025d34c9c846 Mon Sep 17 00:00:00 2001 From: zonble Date: Thu, 3 Feb 2022 01:07:54 +0800 Subject: [PATCH] Bug fixes on the marking state. When the length of the range become to 0, the controller should go back to inputting state. --- Source/InputState.swift | 4 ++-- Source/KeyHandler.mm | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Source/InputState.swift b/Source/InputState.swift index 7e2987d1..c64dcc8c 100644 --- a/Source/InputState.swift +++ b/Source/InputState.swift @@ -245,8 +245,8 @@ class InputState: NSObject { @objc var userPhrase: String { let text = (composingBuffer as NSString).substring(with: markedRange) - let exactBegin = (composingBuffer as NSString).nextUtf16Position(for: markedRange.location) - let exactEnd = (composingBuffer as NSString).previousUtf16Position(for: markedRange.location) + let (exactBegin, _) = (composingBuffer as NSString).characterIndex(from: markedRange.location) + let (exactEnd, _) = (composingBuffer as NSString).characterIndex(from: markedRange.location) let readings = readings[exactBegin..