From c69ef181abe5b4c59ccd2d7fd38dfaf1f1368358 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 9 Aug 2021 10:55:39 +0200 Subject: [PATCH] OutputWindow: Update auto-scroll flag when "Find" changes position In this case, the text edit's scroll bar does not emit a signal, nor is scrollContentsBy() called (Qt bug?). Therefore, we now check the scroll bar position also on a selection change. Note that this will still misbehave for the edge case where you search for something, then scroll back to the bottom, then search for the same string again and find the same result, because in that case the selection does not change. We live with that. Fixes: QTCREATORBUG-26100 Change-Id: Ib5555d9119117dd95c68175c4094bb0fd904f6e5 Reviewed-by: Orgad Shaneh --- src/plugins/coreplugin/outputwindow.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index e04c3cd71d6..138001c104d 100644 --- a/src/plugins/coreplugin/outputwindow.cpp +++ b/src/plugins/coreplugin/outputwindow.cpp @@ -155,6 +155,10 @@ OutputWindow::OutputWindow(Context context, const QString &settingsKey, QWidget connect(verticalScrollBar(), &QAbstractSlider::actionTriggered, this, &OutputWindow::updateAutoScroll); + // For when "Find" changes the position; see QTCREATORBUG-26100. + connect(this, &QPlainTextEdit::selectionChanged, this, &OutputWindow::updateAutoScroll, + Qt::QueuedConnection); + undoAction->setEnabled(false); redoAction->setEnabled(false); cutAction->setEnabled(false); @@ -252,7 +256,7 @@ void OutputWindow::showEvent(QShowEvent *e) { QPlainTextEdit::showEvent(e); if (d->scrollToBottom) - verticalScrollBar()->setValue(verticalScrollBar()->maximum()); + scrollToBottom(); } void OutputWindow::wheelEvent(QWheelEvent *e)