Unverified Commit eadd59a9 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Swap out the moon emoji used for progress spinner for a single-cell character. (#22243)

Swap out the moon emoji used for progress spinner for a single-cell character.

The moon emoji looked cool, but couldn't be used because of bugs in xterm.js, used for VSCode's terminal, among others. The moon emoji is two character cells wide, but xterm.js doesn't advance by two cells when it adds the emoji, but does go back by two when it backspaces.

This changes us to a different character animation (dots) that is only one cell wide, and so doesn't have this problem.
parent a52bd815
...@@ -395,7 +395,7 @@ class AnsiSpinner extends Status { ...@@ -395,7 +395,7 @@ class AnsiSpinner extends Status {
// Windows console font has a limited set of Unicode characters. // Windows console font has a limited set of Unicode characters.
List<String> get _animation => platform.isWindows List<String> get _animation => platform.isWindows
? <String>[r'-', r'\', r'|', r'/'] ? <String>[r'-', r'\', r'|', r'/']
: <String>['🌕', '🌖', '🌗', '🌘', '🌑', '🌒', '🌓', '🌔']; : <String>['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷'];
String get _backspace => '\b' * _animation[0].length; String get _backspace => '\b' * _animation[0].length;
String get _clear => ' ' * _animation[0].length; String get _clear => ' ' * _animation[0].length;
......
...@@ -100,12 +100,12 @@ void main() { ...@@ -100,12 +100,12 @@ void main() {
List<String> lines = outputStdout(); List<String> lines = outputStdout();
expect(lines[0], startsWith(platform.isWindows expect(lines[0], startsWith(platform.isWindows
? ' \b-\b\\\b|\b/\b-\b\\\b|\b/' ? ' \b-\b\\\b|\b/\b-\b\\\b|\b/'
: ' \b\b🌕\b\b🌖\b\b🌗\b\b🌘\b\b🌑\b\b🌒\b\b🌓\b\b🌔\b\b🌕\b\b🌖')); : ' \b\b⣽\b⣻\b⢿\b⡿\b⣟\b⣯\b⣷\b⣾\b⣽'));
expect(lines[0].endsWith('\n'), isFalse); expect(lines[0].endsWith('\n'), isFalse);
expect(lines.length, equals(1)); expect(lines.length, equals(1));
ansiSpinner.stop(); ansiSpinner.stop();
lines = outputStdout(); lines = outputStdout();
expect(lines[0], endsWith(platform.isWindows ? '\b \b' : '\b\b \b\b')); expect(lines[0], endsWith('\b \b'));
expect(lines.length, equals(1)); expect(lines.length, equals(1));
// Verify that stopping or canceling multiple times throws. // Verify that stopping or canceling multiple times throws.
...@@ -128,7 +128,7 @@ void main() { ...@@ -128,7 +128,7 @@ void main() {
final List<String> lines = outputStdout(); final List<String> lines = outputStdout();
expect(outputStderr().length, equals(1)); expect(outputStderr().length, equals(1));
expect(outputStderr().first, isEmpty); expect(outputStderr().first, isEmpty);
expect(lines[0], matches(platform.isWindows ? r'[ ]{64} [\b]-' : r'[ ]{64} [\b][\b]🌕')); expect(lines[0], matches(platform.isWindows ? r'[ ]{64} [\b]-' : r'[ ]{64} [\b]'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Stdio: () => mockStdio, Stdio: () => mockStdio,
Platform: () => FakePlatform(operatingSystem: testOs), Platform: () => FakePlatform(operatingSystem: testOs),
...@@ -141,7 +141,7 @@ void main() { ...@@ -141,7 +141,7 @@ void main() {
List<String> lines = outputStdout(); List<String> lines = outputStdout();
expect(lines[0], startsWith(platform.isWindows expect(lines[0], startsWith(platform.isWindows
? 'Hello world \b-\b\\\b|\b/\b-\b\\\b|\b/' ? 'Hello world \b-\b\\\b|\b/\b-\b\\\b|\b/'
: 'Hello world \b\b🌕\b\b🌖\b\b🌗\b\b🌘\b\b🌑\b\b🌒\b\b🌓\b\b🌔\b\b🌕\b\b🌖')); : 'Hello world \b\b⣽\b⣻\b⢿\b⡿\b⣟\b⣯\b⣷\b⣾\b⣽'));
expect(lines.length, equals(1)); expect(lines.length, equals(1));
expect(lines[0].endsWith('\n'), isFalse); expect(lines[0].endsWith('\n'), isFalse);
...@@ -150,7 +150,7 @@ void main() { ...@@ -150,7 +150,7 @@ void main() {
lines = outputStdout(); lines = outputStdout();
final List<Match> matches = secondDigits.allMatches(lines[0]).toList(); final List<Match> matches = secondDigits.allMatches(lines[0]).toList();
expect(matches, isEmpty); expect(matches, isEmpty);
expect(lines[0], endsWith(platform.isWindows ? '\b \b' : '\b\b \b\b')); expect(lines[0], endsWith('\b \b'));
expect(called, equals(1)); expect(called, equals(1));
expect(lines.length, equals(2)); expect(lines.length, equals(2));
expect(lines[1], equals('')); expect(lines[1], equals(''));
...@@ -169,7 +169,7 @@ void main() { ...@@ -169,7 +169,7 @@ void main() {
List<String> lines = outputStdout(); List<String> lines = outputStdout();
expect(lines[0], startsWith(platform.isWindows expect(lines[0], startsWith(platform.isWindows
? 'Hello world \b-\b\\\b|\b/\b-\b\\\b|\b/' ? 'Hello world \b-\b\\\b|\b/\b-\b\\\b|\b/'
: 'Hello world \b\b🌕\b\b🌖\b\b🌗\b\b🌘\b\b🌑\b\b🌒\b\b🌓\b\b🌔\b\b🌕\b\b🌖')); : 'Hello world \b\b⣽\b⣻\b⢿\b⡿\b⣟\b⣯\b⣷\b⣾\b⣽'));
expect(lines.length, equals(1)); expect(lines.length, equals(1));
// Verify a stop prints the time. // Verify a stop prints the time.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment