mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
When et is not attached to a terminal, still split lines for status updates. (flutter/engine#52681)
For illustrative purposes: ```sh $ et build | grep '.*' ``` ... should still get line-per-line status updates, but it does not without this patch. It's hard to write tests because of global state, so I've declined to do so at the moment. Closes https://github.com/flutter/flutter/issues/147903.
This commit is contained in:
parent
d1b24afe05
commit
8ce9cf6200
@ -165,10 +165,20 @@ class Logger {
|
||||
_emitLog(infoLevel, message, indent, newline, fit);
|
||||
}
|
||||
|
||||
/// Writes a number of spaces to stdout equal to the width of the terminal
|
||||
/// and emits a carriage return.
|
||||
/// Functionally ends and starts a new line.
|
||||
///
|
||||
/// How that is done depends on the terminal capabilities:
|
||||
///
|
||||
/// - If we are not in a terminal, just write a newline.
|
||||
/// - If we are in a a terminal, any spinners are temporarily paused, the
|
||||
/// current line is cleared, and spinners are resumed. If ANSI escapes are
|
||||
/// supported, the cursor is moved to the start of the line and the line is
|
||||
/// cleared. Otherwise, the line is cleared by writing spaces to the width
|
||||
/// of the terminal, then moving the cursor back to the start of the line.
|
||||
void clearLine() {
|
||||
if (!io.stdout.hasTerminal || _test) {
|
||||
// Just write a newline if we're not in a terminal.
|
||||
_ioSinkWrite(io.stdout, '\n');
|
||||
return;
|
||||
}
|
||||
_status?.pause();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user