Skip to content

Commit

Permalink
Disable paging when -P flag or plain mode -pp is active
Browse files Browse the repository at this point in the history
  • Loading branch information
themkat committed May 23, 2022
1 parent e9f8370 commit 575977b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/bin/bat/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,18 @@ impl App {
pub fn config(&self, inputs: &[Input]) -> Result<Config> {
let style_components = self.style_components()?;

let extra_plain = self.matches.occurrences_of("plain") > 1;
let paging_mode = match self.matches.value_of("paging") {
Some("always") => PagingMode::Always,
Some("always") => {
if extra_plain || self.matches.is_present("no-paging") {
PagingMode::Never
} else {
PagingMode::Always
}
}
Some("never") => PagingMode::Never,
Some("auto") | None => {
// If we have -pp as an option when in auto mode, the pager should be disabled.
let extra_plain = self.matches.occurrences_of("plain") > 1;
if extra_plain || self.matches.is_present("no-paging") {
PagingMode::Never
} else if inputs.iter().any(Input::is_stdin) {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ fn alias_pager_disable_long_overrides_short() {
.arg("test.txt")
.assert()
.success()
.stdout(predicate::eq("pager-output\n").normalize());
.stdout(predicate::eq("hello world\n").normalize());
}

#[test]
Expand Down

0 comments on commit 575977b

Please sign in to comment.