From 0ed826a14fc5eca806dc048f67136d22adb22ced Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 8 Sep 2022 22:28:35 +1000 Subject: [PATCH] fix(windows): TSF apps delete all of smp When the windows platform recieves the action for a backspace it will check to see if the character being delete is a surrogate pair. If it is and the app is TSF aware app it will need to backspace twice to remove both parts of the surrogate pair. For legacy apps this is not required. --- windows/src/engine/keyman32/kmprocessactions.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/windows/src/engine/keyman32/kmprocessactions.cpp b/windows/src/engine/keyman32/kmprocessactions.cpp index 6a5e03c123..1e07523925 100644 --- a/windows/src/engine/keyman32/kmprocessactions.cpp +++ b/windows/src/engine/keyman32/kmprocessactions.cpp @@ -30,8 +30,17 @@ static BOOL processAlert(AITIP* app) { static BOOL processBack(AITIP* app, const km_kbp_action_item* actionItem) { if (actionItem->backspace.expected_type == KM_KBP_BT_MARKER) { app->QueueAction(QIT_BACK, BK_DEADKEY); - } else /* actionItem->backspace.expected_type == KM_KBP_BT_CHAR, KM_KBP_BT_UNKNOWN */ { - app->QueueAction(QIT_BACK, 0); + } else if(actionItem->backspace.expected_type == KM_KBP_BT_CHAR) { + // If this is a TSF-aware app we need to set the BK_SURROGATE flag to delete + // both parts of the surrogate pair. Legacy apps receive a BKSP WM_KEYDOWN event + // which results in deleting both parts in one action. + if (!app->IsLegacy() && Uni_IsSMP(actionItem->backspace.expected_value)) { + app->QueueAction(QIT_BACK, BK_DEFAULT | BK_SURROGATE); + } else { + app->QueueAction(QIT_BACK, BK_DEFAULT); + } + } else { // KM_KBP_BT_UNKNOWN + app->QueueAction(QIT_BACK, BK_DEFAULT); } return TRUE; }