From 27d3a141b4110165fff48379592dccf9d0bb5625 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sun, 28 Jun 2020 11:12:50 -0400 Subject: Rearrange: move navigate function to correct location --- src/bat/output.rs | 3 ++- src/config.rs | 10 ---------- src/features/navigate.rs | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/bat/output.rs b/src/bat/output.rs index efb3fafa..3f53ca97 100644 --- a/src/bat/output.rs +++ b/src/bat/output.rs @@ -12,6 +12,7 @@ use super::less::retrieve_less_version; use crate::config; use crate::env; +use crate::features::navigate; #[derive(Debug, Clone, Copy, PartialEq)] #[allow(dead_code)] @@ -125,7 +126,7 @@ impl OutputType { p }; if config.navigate { - process.args(&["--pattern", &config::make_navigate_regexp(&config)]); + process.args(&["--pattern", &navigate::make_navigate_regexp(&config)]); } Ok(process .env("LESSANSIENDCHARS", "mK") diff --git a/src/config.rs b/src/config.rs index d246313a..e4ccab24 100644 --- a/src/config.rs +++ b/src/config.rs @@ -428,16 +428,6 @@ fn make_commit_file_hunk_header_styles(opt: &cli::Opt, true_color: bool) -> (Sty ) } -pub fn make_navigate_regexp(config: &Config) -> String { - format!( - "^(commit|{}|{}|{}|{})", - config.file_modified_label, - config.file_added_label, - config.file_removed_label, - config.file_renamed_label - ) -} - fn _check_validity(opt: &cli::Opt, assets: &HighlightingAssets) { if opt.light && opt.dark { eprintln!("--light and --dark cannot be used together."); diff --git a/src/features/navigate.rs b/src/features/navigate.rs index 8abef729..1175b13b 100644 --- a/src/features/navigate.rs +++ b/src/features/navigate.rs @@ -1,3 +1,4 @@ +use crate::config::Config; use crate::features::OptionValueFunction; pub fn make_feature() -> Vec<(String, OptionValueFunction)> { @@ -17,6 +18,16 @@ pub fn make_feature() -> Vec<(String, OptionValueFunction)> { ]) } +pub fn make_navigate_regexp(config: &Config) -> String { + format!( + "^(commit|{}|{}|{}|{})", + config.file_modified_label, + config.file_added_label, + config.file_removed_label, + config.file_renamed_label + ) +} + #[cfg(test)] mod tests { use std::fs::remove_file; @@ -32,7 +43,10 @@ mod tests { "; let git_config_path = "delta__test_navigate_with_overriden_key_in_main_section.gitconfig"; - assert_eq!(features::tests::make_options(&[], None, None).file_modified_label, ""); + assert_eq!( + features::tests::make_options(&[], None, None).file_modified_label, + "" + ); assert_eq!( features::tests::make_options(&["--features", "navigate"], None, None) .file_modified_label, -- cgit v1.2.3