forked from qt-creator/qt-creator
OutputFormatter: Simplify logic
Change-Id: I092cdb351f7530284e915cd4955973b21f2577b5 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -204,37 +204,33 @@ void OutputFormatter::appendMessage(const QString &text, OutputFormat format)
|
|||||||
out.chop(1);
|
out.chop(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format == ErrorMessageFormat || format == NormalMessageFormat) {
|
if (format != StdOutFormatSameLine && format != StdErrFormatSameLine) {
|
||||||
doAppendMessage(doNewlineEnforcement(out), format);
|
doAppendMessage(doNewlineEnforcement(out), format);
|
||||||
} else {
|
return;
|
||||||
const bool sameLine = format == StdOutFormatSameLine || format == StdErrFormatSameLine;
|
}
|
||||||
if (sameLine) {
|
|
||||||
bool enforceNewline = d->enforceNewline;
|
|
||||||
d->enforceNewline = false;
|
|
||||||
if (enforceNewline) {
|
|
||||||
out.prepend('\n');
|
|
||||||
} else {
|
|
||||||
const int newline = out.indexOf('\n');
|
|
||||||
plainTextEdit()->moveCursor(QTextCursor::End);
|
|
||||||
if (newline != -1) {
|
|
||||||
doAppendMessage(out.left(newline), format);// doesn't enforce new paragraph like appendPlainText
|
|
||||||
out = out.mid(newline);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out.isEmpty()) {
|
const bool enforceNewline = d->enforceNewline;
|
||||||
d->enforceNewline = true;
|
d->enforceNewline = false;
|
||||||
} else {
|
if (enforceNewline) {
|
||||||
if (out.endsWith('\n')) {
|
out.prepend('\n');
|
||||||
d->enforceNewline = true;
|
} else {
|
||||||
out.chop(1);
|
const int newline = out.indexOf('\n');
|
||||||
}
|
plainTextEdit()->moveCursor(QTextCursor::End);
|
||||||
doAppendMessage(out, format);
|
if (newline != -1) {
|
||||||
}
|
doAppendMessage(out.left(newline), format);// doesn't enforce new paragraph like appendPlainText
|
||||||
} else {
|
out = out.mid(newline);
|
||||||
doAppendMessage(doNewlineEnforcement(out), format);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (out.isEmpty()) {
|
||||||
|
d->enforceNewline = true;
|
||||||
|
} else {
|
||||||
|
if (out.endsWith('\n')) {
|
||||||
|
d->enforceNewline = true;
|
||||||
|
out.chop(1);
|
||||||
|
}
|
||||||
|
doAppendMessage(out, format);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OutputFormatter::doNewlineEnforcement(const QString &out)
|
QString OutputFormatter::doNewlineEnforcement(const QString &out)
|
||||||
|
Reference in New Issue
Block a user