From 211a4c8f5cb101104d1709821437ef9f4320e934 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 22 Feb 2022 17:31:39 +0800 Subject: [PATCH] KeyHandler // Commit buffer on calling the symbol menu. - Otherwise, the buffer content will be duplicated (a misbehavior) when pressing ESC to exit the symbol menu. --- Source/Modules/ControllerModules/KeyHandler.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler.mm b/Source/Modules/ControllerModules/KeyHandler.mm index 1986cb0a..eb042f1c 100644 --- a/Source/Modules/ControllerModules/KeyHandler.mm +++ b/Source/Modules/ControllerModules/KeyHandler.mm @@ -509,8 +509,10 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot"; // MARK: Punctuation list if ([input isSymbolMenuKey]) { - InputStateEmpty *empty = [[InputStateEmpty alloc] init]; - stateCallback(empty); + + // 得在這裡先 commit buffer,不然會導致「在摁 ESC 離開符號選單時會重複輸入上一次的組字區的內容」的不當行為。 + // 於是這裡用「模擬一次 Enter 鍵的操作」使其代為執行這個 commit buffer 的動作。 + [self _handleEnterWithState:state stateCallback:stateCallback errorCallback:errorCallback]; SymbolNode *root = [SymbolNode root]; InputStateSymbolTable *symbolState = [[InputStateSymbolTable alloc] initWithNode:root useVerticalMode:input.useVerticalMode];