forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user