Input method event having replacement information out of bounds
left the controller in selection state when it shouldn't be.
Also now more liberal on accepted events. We cannot detect if input
method is confused for replacement inside boundaries, but going beyond
the end is more likely to be meant to replace until the end than to
leave previous text in addition to the new one.
Change-Id: I485009ac682c11876b39f7e22d7dfb91a6d162fe
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
if (event->replacementLength()) {
m_selstart = m_cursor;
m_selend = m_selstart + event->replacementLength();
+ m_selend = qMin(m_selend, m_text.length());
removeSelectedText();
}
if (!event->commitString().isEmpty()) {
QCOMPARE(input->text(), QString(""));
input->setValidator(0);
delete validator;
+
+ // input should reset selection even if replacement parameters are out of bounds
+ input->setText("text");
+ input->setCursorPosition(0);
+ input->moveCursorSelection(input->text().length());
+ event.setCommitString("replacement", -input->text().length(), input->text().length());
+ QGuiApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &event);
+ QCOMPARE(input->selectionStart(), input->selectionEnd());
}
/*