From 056080b59954eba5c2b0e8d20a1594ee47490b61 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 2 Dec 2019 17:32:37 +0100 Subject: [PATCH] Output panes: Fix newline handling On repeated invocations of OutputWindow::appendMessage(), embedded newlines would simply disappear because of an off-by-one error. The only reason this was not observed all the time is that the relevant code is only run for process output, which usually comes in larger chunks, so that the whole output would get procecessed in a single call to appendMessage(). Fixes: QTCREATORBUG-23300 Change-Id: Ibd10d33462d1922671c3cd9325adbbf2841bfa06 Reviewed-by: Alessandro Portale --- src/plugins/coreplugin/outputwindow.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index f920ffc3891..cc87baaa155 100644 --- a/src/plugins/coreplugin/outputwindow.cpp +++ b/src/plugins/coreplugin/outputwindow.cpp @@ -428,20 +428,22 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format) } else { newline = out.indexOf(QLatin1Char('\n')); moveCursor(QTextCursor::End); - if (newline != -1 && d->formatter) - d->formatter->appendMessage(out.left(newline), format);// doesn't enforce new paragraph like appendPlainText + if (newline != -1) { + if (d->formatter) + d->formatter->appendMessage(out.left(newline), format);// doesn't enforce new paragraph like appendPlainText + out = out.mid(newline); + } } - QString s = out.mid(newline+1); - if (s.isEmpty()) { + if (out.isEmpty()) { d->enforceNewline = true; } else { - if (s.endsWith(QLatin1Char('\n'))) { + if (out.endsWith(QLatin1Char('\n'))) { d->enforceNewline = true; - s.chop(1); + out.chop(1); } if (d->formatter) - d->formatter->appendMessage(s, format); + d->formatter->appendMessage(out, format); } } else { if (d->formatter)