summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-06-28 11:12:50 -0400
committerDan Davison <dandavison7@gmail.com>2020-06-28 11:12:50 -0400
commit27d3a141b4110165fff48379592dccf9d0bb5625 (patch)
treec5ca116a3c1c9bd9daf14889470ee65e3384bfce
parentc72af55376fd003de52c78e6c514f7ce78a40d0c (diff)
Rearrange: move navigate function to correct location
-rw-r--r--src/bat/output.rs3
-rw-r--r--src/config.rs10
-rw-r--r--src/features/navigate.rs16
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,