summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/widgets/qlinecontrol.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index 5a281ad..d03e5de 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -435,7 +435,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
removeSelectedText();
}
if (!event->commitString().isEmpty()) {
- insert(event->commitString());
+ internalInsert(event->commitString());
cursorPositionChanged = true;
}
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index ef32ee3..943b1fa 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -2285,6 +2285,20 @@ void tst_qdeclarativetextinput::preeditAutoScroll()
ic.sendPreeditText(preeditText.mid(0, 3), 1);
QCOMPARE(input.positionAt(0), 0);
QCOMPARE(input.positionAt(input.width()), 5);
+
+ ic.sendEvent(QInputMethodEvent());
+ input.setAutoScroll(true);
+ // Test committing pre-edit text at the start of the string. QTBUG-18789
+ input.setCursorPosition(0);
+ ic.sendPreeditText(input.text(), 5);
+ QCOMPARE(input.positionAt(0), 0);
+
+ QInputMethodEvent event;
+ event.setCommitString(input.text());
+ ic.sendEvent(event);
+
+ QCOMPARE(input.positionAt(0), 0);
+ QCOMPARE(input.positionAt(input.width()), 5);
}
void tst_qdeclarativetextinput::preeditMicroFocus()