forked from qt-creator/qt-creator
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:
committed by
Orgad Shaneh
parent
fd7515d3dc
commit
96bd65327b
@@ -99,6 +99,11 @@ void OutputFormatter::append(const QString &text, const QTextCharFormat &format)
|
|||||||
int startPos = 0;
|
int startPos = 0;
|
||||||
int crPos = -1;
|
int crPos = -1;
|
||||||
while ((crPos = text.indexOf('\r', startPos)) >= 0) {
|
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.insertText(text.mid(startPos, crPos - startPos), format);
|
||||||
d->cursor.clearSelection();
|
d->cursor.clearSelection();
|
||||||
d->cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
|
d->cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
|
||||||
|
|||||||
@@ -366,6 +366,8 @@ void AbstractProcessStep::Private::readData(void (AbstractProcessStep::*func)(co
|
|||||||
int startPos = 0;
|
int startPos = 0;
|
||||||
int crPos = -1;
|
int crPos = -1;
|
||||||
while ((crPos = data.indexOf('\r', startPos)) >= 0) {
|
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);
|
processLine(data.mid(startPos, crPos - startPos + 1), func, isUtf8);
|
||||||
startPos = crPos + 1;
|
startPos = crPos + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user