diff --git a/src/app.rs b/src/app.rs index 1946828d..b645e01d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -364,22 +364,24 @@ impl App { let paging_mode = match self.matches.value_of("paging") { Some("always") => PagingMode::Always, Some("never") => PagingMode::Never, - Some("auto") | _ => if files.contains(&InputFile::StdIn) { - // If we are reading from stdin, only enable paging if we write to an - // interactive terminal and if we do not *read* from an interactive - // terminal. - if self.interactive_output && !atty::is(Stream::Stdin) { - PagingMode::QuitIfOneScreen + Some("auto") | _ => { + if files.contains(&InputFile::StdIn) { + // If we are reading from stdin, only enable paging if we write to an + // interactive terminal and if we do not *read* from an interactive + // terminal. + if self.interactive_output && !atty::is(Stream::Stdin) { + PagingMode::QuitIfOneScreen + } else { + PagingMode::Never + } } else { - PagingMode::Never + if self.interactive_output { + PagingMode::QuitIfOneScreen + } else { + PagingMode::Never + } } - } else { - if self.interactive_output { - PagingMode::QuitIfOneScreen - } else { - PagingMode::Never - } - }, + } }; Ok(Config { @@ -393,11 +395,13 @@ impl App { match self.matches.value_of("wrap") { Some("character") => OutputWrap::Character, Some("never") => OutputWrap::None, - Some("auto") | _ => if output_components.plain() { - OutputWrap::None - } else { - OutputWrap::Character - }, + Some("auto") | _ => { + if output_components.plain() { + OutputWrap::None + } else { + OutputWrap::Character + } + } } }, colored_output: match self.matches.value_of("color") { @@ -450,8 +454,10 @@ impl App { } else { InputFile::Ordinary(filename) } - }).collect() - }).unwrap_or_else(|| vec![InputFile::StdIn]) + }) + .collect() + }) + .unwrap_or_else(|| vec![InputFile::StdIn]) } fn output_components(&self) -> Result { diff --git a/src/printer.rs b/src/printer.rs index 99901b35..50a54c02 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -319,7 +319,8 @@ impl<'a> Printer for InteractivePrinter<'a> { .iter() .map(|ref d| d .generate(line_number, true, self) - .text).collect::>() + .text) + .collect::>() .join(" ") )) } else { diff --git a/src/style.rs b/src/style.rs index fe08995f..87356836 100644 --- a/src/style.rs +++ b/src/style.rs @@ -23,11 +23,13 @@ pub enum OutputWrap { impl OutputComponent { pub fn components(&self, interactive_terminal: bool) -> &'static [OutputComponent] { match *self { - OutputComponent::Auto => if interactive_terminal { - OutputComponent::Full.components(interactive_terminal) - } else { - OutputComponent::Plain.components(interactive_terminal) - }, + OutputComponent::Auto => { + if interactive_terminal { + OutputComponent::Full.components(interactive_terminal) + } else { + OutputComponent::Plain.components(interactive_terminal) + } + } OutputComponent::Changes => &[OutputComponent::Changes], OutputComponent::Grid => &[OutputComponent::Grid], OutputComponent::Header => &[OutputComponent::Header], diff --git a/tests/tester.rs b/tests/tester.rs index 87de6462..859c6f12 100644 --- a/tests/tester.rs +++ b/tests/tester.rs @@ -50,7 +50,8 @@ impl BatTester { &format!("--wrap={}", if wrap { "character" } else { "never" }), &format!("--tabs={}", tab_width), &format!("--style={}", style), - ]).output() + ]) + .output() .expect("bat failed"); // have to do the replace because the filename in the header changes based on the current working directory