diff --git a/Source/Modules/ControllerModules/IMEState.swift b/Source/Modules/ControllerModules/IMEState.swift index a8d732e1..ba950e97 100644 --- a/Source/Modules/ControllerModules/IMEState.swift +++ b/Source/Modules/ControllerModules/IMEState.swift @@ -35,6 +35,7 @@ public protocol IMEStateProtocol { var attributedString: NSAttributedString { get } var convertedToInputting: IMEState { get } var isFilterable: Bool { get } + var isMarkedLengthValid: Bool { get } var node: SymbolNode { get set } } @@ -154,6 +155,7 @@ extension IMEState { extension IMEState { public var isFilterable: Bool { data.isFilterable } + public var isMarkedLengthValid: Bool { data.isMarkedLengthValid } public var candidates: [(String, String)] { data.candidates } public var convertedToInputting: IMEState { if type == .ofInputting { return self } diff --git a/Source/Modules/ControllerModules/IMEStateData.swift b/Source/Modules/ControllerModules/IMEStateData.swift index 4e35d393..95ca5b66 100644 --- a/Source/Modules/ControllerModules/IMEStateData.swift +++ b/Source/Modules/ControllerModules/IMEStateData.swift @@ -76,7 +76,11 @@ public struct StateData { ] ) var isFilterable: Bool { - markedTargetExists ? mgrPrefs.allowedMarkLengthRange.contains(markedRange.count) : false + markedTargetExists ? isMarkedLengthValid : false + } + + var isMarkedLengthValid: Bool { + mgrPrefs.allowedMarkLengthRange.contains(markedRange.count) } var attributedStringNormal: NSAttributedString { diff --git a/Source/Modules/ControllerModules/KeyHandler_States.swift b/Source/Modules/ControllerModules/KeyHandler_States.swift index 53128eb1..0f54b7eb 100644 --- a/Source/Modules/ControllerModules/KeyHandler_States.swift +++ b/Source/Modules/ControllerModules/KeyHandler_States.swift @@ -161,7 +161,13 @@ extension KeyHandler { IME.prtDebugIntel("2EAC1F7A") errorCallback() return true - } else if !keyHandlerDelegate.keyHandler(self, didRequestWriteUserPhraseWith: state, addToFilter: false) { + } + if !state.isMarkedLengthValid { + IME.prtDebugIntel("9AAFAC00") + errorCallback() + return true + } + if !keyHandlerDelegate.keyHandler(self, didRequestWriteUserPhraseWith: state, addToFilter: false) { IME.prtDebugIntel("5B69CC8D") errorCallback() return true