From 8a708b437a8674d5fb967b7eede493b9de6112d2 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Wed, 4 Dec 2024 09:27:30 +0100 Subject: [PATCH] Utils: Don't start at end of Markdown document QTextEdit::show will try to scroll so that the cursor is visible. By default the cursor is at the end of the document after ::setMarkdown(). To counteract we reset the cursor to the top. Change-Id: I0e25878f32775de715fd4789d45274492b2981fe Reviewed-by: Alessandro Portale --- src/libs/utils/markdownbrowser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/utils/markdownbrowser.cpp b/src/libs/utils/markdownbrowser.cpp index e15323058cb..84a85eafaf9 100644 --- a/src/libs/utils/markdownbrowser.cpp +++ b/src/libs/utils/markdownbrowser.cpp @@ -413,6 +413,9 @@ void MarkdownBrowser::setMarkdown(const QString &markdown) { document()->setMarkdown(markdown); postProcessDocument(true); + // Reset cursor to start of the document, so that "show" does not + // scroll to the end of the document. + setTextCursor(QTextCursor(document())); } void MarkdownBrowser::postProcessDocument(bool firstTime) const