Disabled tab expansion when decorations and pager are not used.

This commit is contained in:
eth-p 2018-09-10 20:12:13 -07:00
parent 7cdcdbb31d
commit eb6e43b9a9
No known key found for this signature in database
GPG Key ID: 1F8DF8091CD46FBC

View File

@ -16,7 +16,7 @@ use errors::*;
use line_range::LineRange;
use style::{OutputComponent, OutputComponents, OutputWrap};
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum PagingMode {
Always,
QuitIfOneScreen,
@ -353,6 +353,27 @@ impl App {
let files = self.files();
let output_components = self.output_components()?;
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
} else {
PagingMode::Never
}
} else {
if self.interactive_output {
PagingMode::QuitIfOneScreen
} else {
PagingMode::Never
}
},
};
Ok(Config {
true_color: is_truecolor_terminal(),
language: self.matches.value_of("language"),
@ -376,26 +397,7 @@ impl App {
Some("never") => false,
Some("auto") | _ => self.interactive_output,
},
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
} else {
PagingMode::Never
}
} else {
if self.interactive_output {
PagingMode::QuitIfOneScreen
} else {
PagingMode::Never
}
},
},
paging_mode,
term_width: self
.matches
.value_of("terminal-width")
@ -410,7 +412,13 @@ impl App {
.value_of("tabs")
.and_then(|w| w.parse().ok())
.or_else(|| env::var("BAT_TABS").ok().and_then(|w| w.parse().ok()))
.unwrap_or(8),
.unwrap_or(
if output_components.plain() && paging_mode == PagingMode::Never {
0
} else {
8
},
),
theme: self
.matches
.value_of("theme")