From ee521b6ee275c533949d052ca4cb1550a42f5242 Mon Sep 17 00:00:00 2001 From: zonble Date: Fri, 28 Jan 2022 16:59:28 +0800 Subject: [PATCH] Fixes the behavior of the delete and backspace key. --- Source/KeyHandler.mm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/KeyHandler.mm b/Source/KeyHandler.mm index 4e1983e1..5ee9135d 100644 --- a/Source/KeyHandler.mm +++ b/Source/KeyHandler.mm @@ -658,7 +658,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot } InputStateInputting *inputting = [self _buildInputtingState]; - stateCallback(inputting); + if (!inputting.composingBuffer.length) { + InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init]; + stateCallback(empty); + } else { + stateCallback(inputting); + } return YES; } @@ -673,7 +678,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/McBopomofo-visualization.dot _builder->deleteReadingAfterCursor(); [self _walk]; InputStateInputting *inputting = [self _buildInputtingState]; - stateCallback(inputting); + if (!inputting.composingBuffer.length) { + InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init]; + stateCallback(empty); + } else { + stateCallback(inputting); + } } else { errorCallback(); stateCallback(state);