-
Notifications
You must be signed in to change notification settings - Fork 218
Use Stdout.terminalColumns for line length #716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -18,6 +18,23 @@ const _newline = 0xA; | |||
/// The ASCII code for a carriage return character. | |||
const _carriageReturn = 0xD; | |||
|
|||
/// The default line length for output when there isn't a terminal attached to | |||
/// stdout. | |||
const _defaultLineLength = 200; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the fallback should get called out in the commit message.
Why was 200 chosen instead of the old value of 100?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the fallback should get called out in the commit message.
Done.
Why was 200 chosen instead of the old value of 100?
100 was chosen to approximate the average terminal width. Now that we detect the actual width for real terminals, I want to increase the default because it's more likely to come into play in non-width-constrained environments.
lib/src/util/io.dart
Outdated
final int lineLength = () { | ||
try { | ||
return stdout.terminalColumns; | ||
} on UnsupportedError catch (_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] omit the catch
if we are ignoring the caught value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lib/src/util/io.dart
Outdated
@@ -103,6 +120,36 @@ Stream<List<int>> sanitizeForWindows(Stream<List<int>> input) { | |||
}); | |||
} | |||
|
|||
/// Wraps [text] so that it fits within [lineLength], which defaults to | |||
/// [lineLength]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which defaults to [_defaultLineLength]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, it doesn't default at all anymore. Changed.
lib/src/util/io.dart
Outdated
/// [lineLength]. | ||
/// | ||
/// This preserves existing newlines and doesn't consider terminal color escapes | ||
/// part of a word's length. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps call out in the doc comment that words are only split by space and not other whitespace characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Fall back on a 200-character default, which is less likely to obscure test names when printing to a non-terminal destination. Closes #86
Closes #86