diff --git a/Source/Modules/InputHandler_HandleComposition.swift b/Source/Modules/InputHandler_HandleComposition.swift index a98f5c7f..366cb92f 100644 --- a/Source/Modules/InputHandler_HandleComposition.swift +++ b/Source/Modules/InputHandler_HandleComposition.swift @@ -108,7 +108,10 @@ extension InputHandler { } // 將該讀音插入至組字器內的軌格當中。 - compositor.insertKey(readingKey) + if !compositor.insertKey(readingKey) { + delegate.callError("3CF278C9: 得檢查對應的語言模組的 hasUnigramsFor() 是否有誤判之情形。") + return true + } // 讓組字器反爬軌格。 walk() @@ -223,7 +226,10 @@ extension InputHandler { } // 將該讀音插入至組字器內的軌格當中。 - compositor.insertKey(calligrapher) + if !compositor.insertKey(calligrapher) { + delegate.callError("61F6B11F: 得檢查對應的語言模組的 hasUnigramsFor() 是否有誤判之情形。") + return true + } // 讓組字器反爬軌格。 walk() diff --git a/Source/Modules/InputHandler_HandleInput.swift b/Source/Modules/InputHandler_HandleInput.swift index 656e3a55..3d253273 100644 --- a/Source/Modules/InputHandler_HandleInput.swift +++ b/Source/Modules/InputHandler_HandleInput.swift @@ -120,20 +120,19 @@ extension InputHandler { if input.isSpace { /// 倘若沒有在偏好設定內將 Space 空格鍵設為選字窗呼叫用鍵的話……… if !prefs.chooseCandidateUsingSpace { - if compositor.cursor >= compositor.length { - let displayedText = state.displayedText - if !displayedText.isEmpty { - delegate.switchState(IMEState.ofCommitting(textToCommit: displayedText)) - } - delegate.switchState(IMEState.ofCommitting(textToCommit: " ")) - } else if currentLM.hasUnigramsFor(key: " ") { - compositor.insertKey(" ") + if compositor.cursor < compositor.length, compositor.insertKey(" ") { walk() // 一邊吃一邊屙(僅對位列黑名單的 App 用這招限制組字區長度)。 let textToCommit = commitOverflownComposition var inputting = generateStateOfInputting() inputting.textToCommit = textToCommit delegate.switchState(inputting) + } else { + let displayedText = state.displayedText + if !displayedText.isEmpty { + delegate.switchState(IMEState.ofCommitting(textToCommit: displayedText)) + } + delegate.switchState(IMEState.ofCommitting(textToCommit: " ")) } return true } else if input.isShiftHold { // 臉書等網站會攔截 Tab 鍵,所以用 Shift+Command+Space 對候選字詞做正向/反向輪替。 @@ -182,8 +181,7 @@ extension InputHandler { if input.isSymbolMenuPhysicalKey, !input.isShiftHold, !input.isControlHold, state.type != .ofDeactivated { if input.isOptionHold { if currentLM.hasUnigramsFor(key: "_punctuation_list") { - if isComposerOrCalligrapherEmpty { - compositor.insertKey("_punctuation_list") + if isComposerOrCalligrapherEmpty, compositor.insertKey("_punctuation_list") { walk() // 一邊吃一邊屙(僅對位列黑名單的 App 用這招限制組字區長度)。 let textToCommit = commitOverflownComposition diff --git a/Source/Modules/InputHandler_States.swift b/Source/Modules/InputHandler_States.swift index ca1f65d1..a167e4d1 100644 --- a/Source/Modules/InputHandler_States.swift +++ b/Source/Modules/InputHandler_States.swift @@ -235,7 +235,12 @@ extension InputHandler { return true } - compositor.insertKey(customPunctuation) + guard compositor.insertKey(customPunctuation) else { + delegate.callError("C0793A6D: 得檢查對應的語言模組的 hasUnigramsFor() 是否有誤判之情形。") + delegate.switchState(state) + return true + } + walk() // 一邊吃一邊屙(僅對位列黑名單的 App 用這招限制組字區長度)。 let textToCommit = commitOverflownComposition