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. Task-number: QTBUG-67836 Change-Id: Ia83963780fb14b3c571dbbe3eb81fbbe20fbf412 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
8d7af27e42
commit
6cece0f43a
@ -1977,8 +1977,12 @@ void QWidgetTextControlPrivate::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);
|
||||
@ -1997,7 +2001,8 @@ void QWidgetTextControlPrivate::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());
|
||||
|
Loading…
Reference in New Issue
Block a user