Fix issue with snippet variables not behaving correctly on Gnome

Directly after triggering the snippet completion, a funny input method
event is sent that doesn't contain any data. This still results in a
even more funny contentsChanged signal from QPlainTextEdit which made
our text editor think that the document has changed somewhere else. In
which case we close the snippet variable input.
So ignore funny input method events.

Task-number: QTCREATORBUG-19571
Change-Id: I3958e8736b1b3e3dea5225356ee4cd173d6beaa0
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2018-03-01 14:12:06 +01:00
parent 994a68280e
commit e693c9a02e

View File

@@ -2998,6 +2998,14 @@ bool TextEditorWidget::event(QEvent *e)
void TextEditorWidget::inputMethodEvent(QInputMethodEvent *e)
{
if (e->commitString().isEmpty() && e->preeditString().isEmpty() && e->attributes().isEmpty()) {
// Avoid doing anything when getting bogus events as it can happen on Gnome desktop.
// Otherwise QPlainTextEdit will report content changes for locations where factually
// nothing changed.
// Workaround for QTCREATORBUG-19571
e->accept();
return;
}
if (d->m_inBlockSelectionMode) {
if (!e->commitString().isEmpty())
d->insertIntoBlockSelection(e->commitString());