summaryrefslogtreecommitdiffstats
path: root/src/options/set.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/options/set.rs')
-rw-r--r--src/options/set.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/options/set.rs b/src/options/set.rs
index 732806a7..f6d293e9 100644
--- a/src/options/set.rs
+++ b/src/options/set.rs
@@ -43,6 +43,7 @@ macro_rules! set_options {
"24-bit-color",
"diff-highlight", // Does not exist as a flag on config
"diff-so-fancy", // Does not exist as a flag on config
+ "detect-dark-light", // Does not exist as a flag on config
"features", // Processed differently
// Set prior to the rest
"no-gitconfig",
@@ -78,7 +79,7 @@ pub fn set_options(
}
opt.navigate = opt.navigate || opt.env.navigate.is_some();
if opt.syntax_theme.is_none() {
- opt.syntax_theme = opt.env.bat_theme.clone();
+ opt.syntax_theme.clone_from(&opt.env.bat_theme);
}
let option_names = cli::Opt::get_argument_and_option_names();
@@ -578,7 +579,7 @@ fn parse_width_specifier(width_arg: &str, terminal_width: usize) -> Result<usize
let width = match width_arg.find('-') {
None => parse(width_arg, false, false)?.try_into().unwrap(),
- Some(index) if index == 0 => (terminal_width as isize + parse(width_arg, true, false)?)
+ Some(0) => (terminal_width as isize + parse(width_arg, true, false)?)
.try_into()
.map_err(|_| {
format!(
@@ -631,7 +632,7 @@ fn set_true_color(opt: &mut cli::Opt) {
// It's equal to its default, so the user might be using the deprecated
// --24-bit-color option.
if let Some(_24_bit_color) = opt._24_bit_color.as_ref() {
- opt.true_color = _24_bit_color.clone();
+ opt.true_color.clone_from(_24_bit_color);
}
}
@@ -730,11 +731,11 @@ pub mod tests {
);
assert_eq!(opt.true_color, "never");
- assert_eq!(opt.color_only, false);
+ assert!(!opt.color_only);
assert_eq!(opt.commit_decoration_style, "black black");
assert_eq!(opt.commit_style, "black black");
- assert_eq!(opt.dark, false);
- assert_eq!(opt.default_language, Some("rs".to_owned()));
+ assert!(!opt.dark);
+ assert_eq!(opt.default_language, "rs".to_owned());
// TODO: should set_options not be called on any feature flags?
// assert_eq!(opt.diff_highlight, true);
// assert_eq!(opt.diff_so_fancy, true);
@@ -753,9 +754,9 @@ pub mod tests {
assert_eq!(opt.file_regex_replacement, Some("s/foo/bar/".to_string()));
assert_eq!(opt.hunk_header_decoration_style, "black black");
assert_eq!(opt.hunk_header_style, "black black");
- assert_eq!(opt.keep_plus_minus_markers, true);
- assert_eq!(opt.light, true);
- assert_eq!(opt.line_numbers, true);
+ assert!(opt.keep_plus_minus_markers);
+ assert!(opt.light);
+ assert!(opt.line_numbers);
assert_eq!(opt.line_numbers_left_format, "xxxyyyzzz");
assert_eq!(opt.line_numbers_left_style, "black black");
assert_eq!(opt.line_numbers_minus_style, "black black");
@@ -769,15 +770,15 @@ pub mod tests {
assert_eq!(opt.minus_empty_line_marker_style, "black black");
assert_eq!(opt.minus_non_emph_style, "black black");
assert_eq!(opt.minus_style, "black black");
- assert_eq!(opt.navigate, true);
+ assert!(opt.navigate);
assert_eq!(opt.navigate_regex, Some("xxxyyyzzz".to_string()));
assert_eq!(opt.paging_mode, "never");
assert_eq!(opt.plus_emph_style, "black black");
assert_eq!(opt.plus_empty_line_marker_style, "black black");
assert_eq!(opt.plus_non_emph_style, "black black");
assert_eq!(opt.plus_style, "black black");
- assert_eq!(opt.raw, true);
- assert_eq!(opt.side_by_side, true);
+ assert!(opt.raw);
+ assert!(opt.side_by_side);
assert_eq!(opt.syntax_theme, Some("xxxyyyzzz".to_string()));
assert_eq!(opt.tab_width, 77);
assert_eq!(opt.true_color, "never");