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:
committed by
GitHub
parent
b70d260b3c
commit
ec93c87c89
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user