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.
This commit is contained in:
ShikiSuen 2022-02-22 17:31:39 +08:00
parent 1ee15ac800
commit a5b5a04a24
1 changed files with 4 additions and 2 deletions

View File

@ -509,8 +509,10 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
// MARK: Punctuation list // MARK: Punctuation list
if ([input isSymbolMenuKey]) { 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]; SymbolNode *root = [SymbolNode root];
InputStateSymbolTable *symbolState = [[InputStateSymbolTable alloc] initWithNode:root useVerticalMode:input.useVerticalMode]; InputStateSymbolTable *symbolState = [[InputStateSymbolTable alloc] initWithNode:root useVerticalMode:input.useVerticalMode];