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 <orgads@gmail.com>
This commit is contained in:
Christian Kandeler
2021-08-09 10:55:39 +02:00
parent b8b6af0dbb
commit c69ef181ab

View File

@@ -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)