From 5f45c36b6f665babe67d3cb0c805a13ee1e3ef2c Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 20 Oct 2023 09:03:09 +0200 Subject: [PATCH] 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 --- src/plugins/texteditor/texteditor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 66e3616af91..4a87ecc62af 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -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(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(d->m_cursors).setCursors({c}); + QPlainTextEdit::selectAll(); } void TextEditorWidget::copy()