diff --git a/windows/src/engine/keyman32/appint/appint.cpp b/windows/src/engine/keyman32/appint/appint.cpp index aaccab9c3c..cd067e8f9e 100644 --- a/windows/src/engine/keyman32/appint/appint.cpp +++ b/windows/src/engine/keyman32/appint/appint.cpp @@ -84,8 +84,11 @@ WCHAR *AppContext::BufMax(int n) // Used only by IMX DLLs void AppContext::Delete() { - if(CharIsDeadkey()) pos -= 2; - + if (CharIsDeadkey()) { + pos -= 2; + } else if (CharIsSurrogatePair()) { + pos--; + } //SendDebugMessageFormat(0, sdmAIDefault, 0, "AppContext::Delete"); if(pos > 0) pos--; @@ -144,6 +147,15 @@ BOOL AppContext::CharIsDeadkey() CurContext[pos-2] == CODE_DEADKEY; } +BOOL AppContext::CharIsSurrogatePair() +{ + if (pos < 2) // low_surrogate, high_surrogate + return FALSE; + + return Uni_IsSurrogate1(CurContext[pos - 2]) && + Uni_IsSurrogate2(CurContext[pos - 1]); +} + /* AppActionQueue */ AppActionQueue::AppActionQueue() diff --git a/windows/src/engine/keyman32/appint/appint.h b/windows/src/engine/keyman32/appint/appint.h index 3378327a50..0b0d9025fe 100644 --- a/windows/src/engine/keyman32/appint/appint.h +++ b/windows/src/engine/keyman32/appint/appint.h @@ -95,6 +95,7 @@ public: WCHAR *BufMax(int n); WCHAR *Buf(int n); BOOL CharIsDeadkey(); + BOOL CharIsSurrogatePair(); }; class AppContextWithStores : public AppContext // I4978