Fix delete surounding text boundary check

This commit is contained in:
Weng Xuetian 2020-12-08 21:14:09 -08:00
parent 29a82227bb
commit 1c155eae30
No known key found for this signature in database
GPG Key ID: 8E8B898CBF2412F9
2 changed files with 5 additions and 5 deletions

View File

@ -472,7 +472,7 @@ void QFcitxInputContext::deleteSurroundingText(int offset,
// validates
if (nchar >= 0 && cursor + offset >= 0 &&
cursor + offset + nchar < ucsText.size()) {
cursor + offset + nchar <= ucsText.size()) {
// order matters
QVector<unsigned int> replacedChars =
ucsText.mid(cursor + offset, nchar);
@ -484,7 +484,7 @@ void QFcitxInputContext::deleteSurroundingText(int offset,
start = cursor;
len = offset;
} else {
start = cursor;
start = cursor + offset;
len = -offset;
}

View File

@ -366,7 +366,7 @@ void QFcitxPlatformInputContext::setFocusObject(QObject *object) {
if (window != lastWindow_) {
return;
}
if (auto *proxy = validICByWindow(window.data())) {
if (validICByWindow(window.data())) {
cursorRectChanged();
}
},
@ -577,7 +577,7 @@ void QFcitxPlatformInputContext::deleteSurroundingText(int offset,
// validates
if (nchar >= 0 && cursor + offset >= 0 &&
cursor + offset + nchar < static_cast<int>(ucsText.size())) {
cursor + offset + nchar <= static_cast<int>(ucsText.size())) {
// order matters
auto replacedChars = ucsText.substr(cursor + offset, nchar);
nchar = QString::fromUcs4(replacedChars.data(), replacedChars.size())
@ -588,7 +588,7 @@ void QFcitxPlatformInputContext::deleteSurroundingText(int offset,
start = cursor;
len = offset;
} else {
start = cursor;
start = cursor + offset;
len = -offset;
}