Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

When et is not attached to a terminal, still split lines for status updates. #52681

Merged
merged 3 commits into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions tools/engine_tool/lib/src/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the doc comment for the behavior change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return;
}
_status?.pause();
Expand Down