Skip to content

Commit

Permalink
Honor pager path when checking less version
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Nov 13, 2024
1 parent 1dd35d6 commit 2f2d7c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/utils/bat/less.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use std::path::PathBuf;
use std::process::Command;

pub fn retrieve_less_version() -> Option<usize> {
if let Ok(less_path) = grep_cli::resolve_binary("less") {
let cmd = Command::new(less_path).arg("--version").output().ok()?;
parse_less_version(&cmd.stdout)
} else {
None
}
pub fn retrieve_less_version(less_path: PathBuf) -> Option<usize> {
let cmd = Command::new(less_path).arg("--version").output().ok()?;
parse_less_version(&cmd.stdout)
}

fn parse_less_version(output: &[u8]) -> Option<usize> {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/bat/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn _make_process_from_less_path(
config: &PagerCfg,
) -> Option<Command> {
if let Ok(less_path) = grep_cli::resolve_binary(less_path) {
let mut p = Command::new(less_path);
let mut p = Command::new(less_path.clone());
if args.is_empty() || replace_arguments_to_less {
p.args(vec!["--RAW-CONTROL-CHARS"]);

Expand All @@ -190,7 +190,7 @@ fn _make_process_from_less_path(
//
// For newer versions (530 or 558 on Windows), we omit '--no-init' as it
// is not needed anymore.
match retrieve_less_version() {
match retrieve_less_version(less_path) {
None => {
p.arg("--no-init");
}
Expand Down

0 comments on commit 2f2d7c5

Please sign in to comment.