From 02535d6bf8515453b27eaf18e2a7e3e48c825cbf Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 4 Jan 2022 12:17:20 +0100 Subject: [PATCH] Editor: fix select all Prevent scrolling to the end of the document after triggering select all. Fixes: QTCREATORBUG-26736 Change-Id: I744dddee87ac16ae2399d37483552fc6b535df46 Reviewed-by: Eike Ziller --- src/plugins/texteditor/texteditor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index d558c58c743..3253fddb3c7 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -7237,9 +7237,10 @@ void TextEditorWidget::cut() void TextEditorWidget::selectAll() { - QTextCursor c = textCursor(); - c.select(QTextCursor::Document); - doSetTextCursor(c); + 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()}); } void TextEditorWidget::copy()