diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-12-02 17:32:37 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-12-04 09:18:11 +0000 |
commit | 056080b59954eba5c2b0e8d20a1594ee47490b61 (patch) | |
tree | f0672881af355b0b417c37e0262d93ad69a6e4a6 | |
parent | a198b37eda511e24a8bffefbca20e9ffffd2cf4b (diff) | |
download | qt-creator-056080b59954eba5c2b0e8d20a1594ee47490b61.tar.gz |
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 <alessandro.portale@qt.io>
-rw-r--r-- | src/plugins/coreplugin/outputwindow.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index f920ffc389..cc87baaa15 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) |