summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2018-04-26 13:53:54 +0200
committerPaul Olav Tvete <paul.tvete@qt.io>2018-05-14 10:15:25 +0000
commit9ef0d2da99f4593d50c16912d00bef121bb76f9b (patch)
tree7b5b4b10ba9cf823c6e36d11dcc3c9983c3e4828
parenta6b740869d369dacb8700042aa5da35183a03b5a (diff)
Fix for input method commit that ends with newline
If the input method event contains a commit text that ends with a newline, text, the commit string is inserted first. This changes the current block. This change makes sure that we apply the formatting changes (including removing the old preedit text) to the old block in this specific case. This is a copy of change 6cece0f43a18dc8c9dbf5bc49ce515714f090725 in qtbase, since the code is duplicated. Task-number: QTBUG-67836 Change-Id: I531d3f1dce51d840acc0ef7fda9e7affb3192327 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-rw-r--r--src/quick/items/qquicktextcontrol.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index e3080dfe48..1cb12235c1 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -1304,8 +1304,12 @@ void QQuickTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
cursor.removeSelectedText();
}
+ QTextBlock block;
+
// insert commit string
if (!e->commitString().isEmpty() || e->replacementLength()) {
+ if (e->commitString().endsWith(QChar::LineFeed))
+ block = cursor.block(); // Remember the block where the preedit text is
QTextCursor c = cursor;
c.setPosition(c.position() + e->replacementStart());
c.setPosition(c.position() + e->replacementLength(), QTextCursor::KeepAnchor);
@@ -1324,7 +1328,9 @@ void QQuickTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
}
}
- QTextBlock block = cursor.block();
+ if (!block.isValid())
+ block = cursor.block();
+
QTextLayout *layout = block.layout();
if (isGettingInput) {
layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());