Move spinner _defaultSlowWarning message to a new line (#30071)

* write newline before adding slow restart message to spinner
* update existing test
This commit is contained in:
Christopher Fujino
2019-03-28 10:08:44 -07:00
committed by GitHub
parent b70d260b3c
commit ec93c87c89
2 changed files with 11 additions and 4 deletions

View File

@@ -620,6 +620,8 @@ class AnsiSpinner extends Status {
final String _backspaceChar = '\b';
final String _clearChar = ' ';
bool timedOut = false;
int ticks = 0;
Timer timer;
@@ -660,15 +662,19 @@ class AnsiSpinner extends Status {
assert(timer.isActive);
stdout.write(_backspace);
ticks += 1;
stdout.write('${_clearChar * spinnerIndent}$_currentAnimationFrame');
if (seemsSlow) {
if (!timedOut) {
timedOut = true;
stdout.write('$_clear\n');
}
if (slowWarningCallback != null) {
_slowWarning = ' ' + slowWarningCallback();
_slowWarning = slowWarningCallback();
} else {
_slowWarning = ' ' + _defaultSlowWarning;
_slowWarning = _defaultSlowWarning;
}
stdout.write(_slowWarning);
}
stdout.write('${_clearChar * spinnerIndent}$_currentAnimationFrame');
}
@override

View File

@@ -148,7 +148,8 @@ void main() {
await tenMillisecondsLater;
doWhileAsync(time, () => ansiSpinner.ticks < 30); // three seconds
expect(ansiSpinner.seemsSlow, isTrue);
expect(outputStdout().join('\n'), contains('This is taking an unexpectedly long time.'));
// Check the 2nd line to verify there's a newline before the warning
expect(outputStdout()[1], contains('This is taking an unexpectedly long time.'));
ansiSpinner.stop();
expect(outputStdout().join('\n'), isNot(contains('(!)')));
done = true;