OutputFormatter/AbstractProcessStep: Handle \r\n as newline

\r\n means newline. It shouldn't erase the previous line.

Change-Id: I22d9919c9c0277e4c0932eba535dbfb84a1d5e71
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Orgad Shaneh
2018-11-27 10:19:14 +02:00
committed by Orgad Shaneh
parent fd7515d3dc
commit 96bd65327b
2 changed files with 7 additions and 0 deletions

View File

@@ -99,6 +99,11 @@ void OutputFormatter::append(const QString &text, const QTextCharFormat &format)
int startPos = 0;
int crPos = -1;
while ((crPos = text.indexOf('\r', startPos)) >= 0) {
if (text.size() > crPos + 1 && text.at(crPos + 1) == '\n') {
d->cursor.insertText(text.mid(startPos, crPos - startPos) + '\n', format);
startPos = crPos + 2;
continue;
}
d->cursor.insertText(text.mid(startPos, crPos - startPos), format);
d->cursor.clearSelection();
d->cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);

View File

@@ -366,6 +366,8 @@ void AbstractProcessStep::Private::readData(void (AbstractProcessStep::*func)(co
int startPos = 0;
int crPos = -1;
while ((crPos = data.indexOf('\r', startPos)) >= 0) {
if (data.size() > crPos + 1 && data.at(crPos + 1) == '\n')
break;
processLine(data.mid(startPos, crPos - startPos + 1), func, isUtf8);
startPos = crPos + 1;
}