forked from mirrors/jj
cli: remove redundant maybe_tty flag
It should be valid to test isatty(stdout) even if the output stream is paged.
This commit is contained in:
parent
0633856ab2
commit
87bcdd4e51
1 changed files with 4 additions and 5 deletions
|
@ -65,11 +65,11 @@ fn color_setting(settings: &UserSettings) -> ColorChoice {
|
|||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn use_color(choice: ColorChoice, maybe_tty: bool) -> bool {
|
||||
fn use_color(choice: ColorChoice) -> bool {
|
||||
match choice {
|
||||
ColorChoice::Always => true,
|
||||
ColorChoice::Never => false,
|
||||
ColorChoice::Auto => maybe_tty && atty::is(Stream::Stdout),
|
||||
ColorChoice::Auto => atty::is(Stream::Stdout),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ impl Ui {
|
|||
}
|
||||
|
||||
pub fn with_cwd(cwd: PathBuf, settings: UserSettings) -> Ui {
|
||||
let color = use_color(color_setting(&settings), true);
|
||||
let color = use_color(color_setting(&settings));
|
||||
let formatter_factory = FormatterFactory::prepare(&settings, color);
|
||||
Ui {
|
||||
cwd,
|
||||
|
@ -95,8 +95,7 @@ impl Ui {
|
|||
|
||||
/// Reconfigures the underlying outputs with the new color choice.
|
||||
pub fn reset_color(&mut self, choice: ColorChoice) {
|
||||
let maybe_tty = matches!(&self.output_pair, UiOutputPair::Terminal { .. });
|
||||
let color = use_color(choice, maybe_tty);
|
||||
let color = use_color(choice);
|
||||
if self.formatter_factory.is_color() != color {
|
||||
self.formatter_factory = FormatterFactory::prepare(&self.settings, color);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue