in flutter-idea/src/io/flutter/utils/StdoutJsonParser.java [29:82]
public void appendOutput(String string) {
for (int i = 0; i < string.length(); ++i) {
final char c = string.charAt(i);
if (eatNextEol) {
eatNextEol = false;
if (c == '\n') {
continue;
}
if (c == '\r' && !isPotentialWindowsReturn) {
eatNextEol = true;
isPotentialWindowsReturn = true;
continue;
}
}
if (isPotentialWindowsReturn) {
isPotentialWindowsReturn = false;
if (c != '\n') {
flushLine();
}
}
buffer.append(c);
if (!bufferIsJson && buffer.length() == 2 && buffer.charAt(0) == '[' && c == '{') {
bufferIsJson = true;
}
else if (bufferIsJson && c == ']' && possiblyTerminatesJson(buffer, string, i)) {
flushLine();
}
if (c == '\n') {
flushLine();
}
if (c == '\r') {
// Wait and decide whether to flush depending on next character.
isPotentialWindowsReturn = true;
}
}
// Eagerly flush if we are not within JSON so regular log text is written as soon as possible.
if (!bufferIsJson) {
flushLine();
}
else if (buffer.toString().endsWith("}]")) {
eatNextEol = true;
flushLine();
}
}