From be1e023016172ab4bed945df6d6bd15f9b6e1c45 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 16 Feb 2022 16:34:25 +0800 Subject: [PATCH] UserPhrases // Separating the conditioning of validity and duplication. --- Source/Modules/ControllerModules/InputState.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Modules/ControllerModules/InputState.swift b/Source/Modules/ControllerModules/InputState.swift index 94f37529..24151063 100644 --- a/Source/Modules/ControllerModules/InputState.swift +++ b/Source/Modules/ControllerModules/InputState.swift @@ -246,12 +246,16 @@ class InputState: NSObject { if markedRange.length > kMaxMarkRangeLength { return false } + return markedRange.length >= kMinMarkRangeLength && markedRange.length <= kMaxMarkRangeLength + } + + @objc var chkIfUserPhraseExists: Bool { let text = (composingBuffer as NSString).substring(with: markedRange) let (exactBegin, _) = (composingBuffer as NSString).characterIndex(from: markedRange.location) let (exactEnd, _) = (composingBuffer as NSString).characterIndex(from: markedRange.location + markedRange.length) let selectedReadings = readings[exactBegin..