Pressing backspace corrupts cached context with SMP characters

This commit is contained in:
Marc Durdin 2018-04-11 11:52:47 +07:00
parent dcb70b8dfd
commit 3ffa329f20
2 changed files with 15 additions and 2 deletions

View file

@ -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()

View file

@ -95,6 +95,7 @@ public:
WCHAR *BufMax(int n);
WCHAR *Buf(int n);
BOOL CharIsDeadkey();
BOOL CharIsSurrogatePair();
};
class AppContextWithStores : public AppContext // I4978