From 2c3bd26b73559c840cf250a45efd963ef5819f28 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 1 May 2023 20:25:50 +0800 Subject: [PATCH] InputHandler // Fix several issues with Pinyin handling. - Stop committing unfinished pinyin. - Detect isReadingKeyNotEmpty for Tekkon RomajiBuffer. --- Source/Modules/InputHandler_HandleComposition.swift | 6 +++++- Source/Modules/InputHandler_HandleInput.swift | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Modules/InputHandler_HandleComposition.swift b/Source/Modules/InputHandler_HandleComposition.swift index 5c150541..4ec8deab 100644 --- a/Source/Modules/InputHandler_HandleComposition.swift +++ b/Source/Modules/InputHandler_HandleComposition.swift @@ -86,7 +86,11 @@ extension InputHandler { // 這裡必須使用 composer.value.isEmpty,因為只有這樣才能真正檢測 composer 是否已經有陰平聲調了。 composeReading = composeReading || (!composer.isEmpty && confirmCombination) // readingKey 不能為空。 - composeReading = composeReading && !readingKey.isEmpty + var isReadingKeyNotEmpty = !readingKey.isEmpty + if isComposerUsingPinyin { + isReadingKeyNotEmpty = isReadingKeyNotEmpty || !composer.romajiBuffer.isEmpty + } + composeReading = composeReading && isReadingKeyNotEmpty if composeReading { if input.isControlHold, input.isCommandHold, input.isEnter, !input.isOptionHold, !input.isShiftHold, compositor.isEmpty diff --git a/Source/Modules/InputHandler_HandleInput.swift b/Source/Modules/InputHandler_HandleInput.swift index 4d3b87d9..860e13fd 100644 --- a/Source/Modules/InputHandler_HandleInput.swift +++ b/Source/Modules/InputHandler_HandleInput.swift @@ -207,7 +207,7 @@ extension InputHandler { delegate.switchState(inputting) } else { let displayedText = state.displayedText - if !displayedText.isEmpty { + if !displayedText.isEmpty, !isConsideredEmptyForNow { delegate.switchState(IMEState.ofCommitting(textToCommit: displayedText)) } delegate.switchState(IMEState.ofCommitting(textToCommit: " "))