Android: If there is no surrounding text then don't try to delete it

If there is no surrounding text then we can save time by not sending an
event to delete it as there is nothing to be deleted. This prevents the
underlying widget from being confused as to where the cursor and anchor
is later on when entering in new text.

Fixes: QTBUG-65584
Change-Id: Ic6325c119327048dffd2baa68520871fb56370d5
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
bb10
Andy Shaw 2019-01-22 14:36:04 +01:00
parent f92ca83230
commit cf184f1dd4
1 changed files with 4 additions and 0 deletions

View File

@ -978,6 +978,10 @@ jboolean QAndroidInputContext::deleteSurroundingText(jint leftLength, jint right
m_composingText.clear();
m_composingTextStart = -1;
QString text = query->value(Qt::ImSurroundingText).toString();
if (text.isEmpty())
return JNI_TRUE;
if (leftLength < 0) {
rightLength += -leftLength;
leftLength = 0;