TextEditor: do not scroll to cursor postion on select all

Since Qt 6.5.1 QPlainTextEdit::selectAll emits correctly
cursorPositionChanged on selectAll which calls some multitextcursor
update code on our side. Avoid setting the cursor back to the
QPlainTextEdit in this update code by setting the expected
MultiTextCursor before calling selectAll.

Fixes: QTCREATORBUG-29763
Change-Id: I77f05ac40a9dd126efcd72089a699c908c68da21
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2023-10-20 09:03:09 +02:00
parent fe129cc0c4
commit 5f45c36b6f

View File

@@ -8038,10 +8038,12 @@ void TextEditorWidget::cut()
void TextEditorWidget::selectAll()
{
QPlainTextEdit::selectAll();
// Directly update the internal multi text cursor here to prevent calling setTextCursor.
// This would indirectly makes sure the cursor is visible which is not desired for select all.
const_cast<MultiTextCursor &>(d->m_cursors).setCursors({QPlainTextEdit::textCursor()});
// This would indirectly make sure the cursor is visible which is not desired for select all.
QTextCursor c = QPlainTextEdit::textCursor();
c.select(QTextCursor::Document);
const_cast<MultiTextCursor &>(d->m_cursors).setCursors({c});
QPlainTextEdit::selectAll();
}
void TextEditorWidget::copy()