TextEditor: set the cursor to the widget before closing the edit block

This will make sure that code reacting on the document change signal can
get the final cursor position from the widget. More specificly this
fixes requesting copilot suggestions when automatic text is inserted
like closing parentheses when typing "if ("

Change-Id: I01a13e67e72b89010fe39de3d0def0622a9b08b8
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
David Schulz
2023-03-16 14:45:18 +01:00
parent 97d8b9fe67
commit 65e1baf5f7
2 changed files with 4 additions and 3 deletions

View File

@@ -2894,13 +2894,13 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
if (!autoText.isEmpty())
cursor.setPosition(autoText.length() == 1 ? cursor.position() : cursor.anchor());
setTextCursor(cursor);
if (doEditBlock) {
cursor.endEditBlock();
if (cursorWithinSnippet)
d->m_snippetOverlay->updateEquivalentSelections(textCursor());
}
setTextCursor(cursor);
}
if (!ro && e->key() == Qt::Key_Delete && d->m_parenthesesMatchingEnabled)