forked from qt-creator/qt-creator
Editor: fix crash when text is auto completed outside of visible area
Setting a text cursor also ensures that the cursor is visible. If this operation is done inside a begin/endEditBlock we might operate on an outdated layout which returns a potentially invalid line that causes an assert in the code that ensured the cursor is visible. closing the edit block before setting the text cursor makes sure the layout is invalidated and correctly recalculated before ensuring that the cursor is visible. Fixes: QTCREATORBUG-32401 Change-Id: Ibb6913a8fef9b0d0178f4da0cf9044a25f622007 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -3225,13 +3225,13 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
|
||||
if (!autoText.isEmpty())
|
||||
cursor.setPosition(autoText.length() == 1 ? cursor.position() : cursor.anchor());
|
||||
|
||||
if (doEditBlock)
|
||||
cursor.endEditBlock();
|
||||
|
||||
setTextCursor(cursor);
|
||||
|
||||
if (doEditBlock) {
|
||||
cursor.endEditBlock();
|
||||
if (cursorWithinSnippet)
|
||||
d->m_snippetOverlay->updateEquivalentSelections(textCursor());
|
||||
}
|
||||
if (doEditBlock && cursorWithinSnippet)
|
||||
d->m_snippetOverlay->updateEquivalentSelections(textCursor());
|
||||
}
|
||||
|
||||
if (!ro && e->key() == Qt::Key_Delete && d->m_parenthesesMatchingEnabled)
|
||||
|
Reference in New Issue
Block a user