diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-08-28 21:57:37 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-08-28 21:57:37 -0400 |
commit | 93aabce9490d566d184579a0f9a182fd3cbf1d48 (patch) | |
tree | d35e39f76d062bf262b49861c6b70d306aefd141 | |
parent | 19eec9bd3e037cd542dfafa40e067098fad917ac (diff) |
Set a default blame palette
-rw-r--r-- | src/cli.rs | 4 | ||||
-rw-r--r-- | src/config.rs | 12 | ||||
-rw-r--r-- | src/delta.rs | 9 |
3 files changed, 10 insertions, 15 deletions
@@ -430,8 +430,8 @@ pub struct Opt { /// Background colors used for git blame lines (space-separated string). /// Lines added by the same commit are painted with the same color; colors /// are recycled as needed. - #[structopt(long = "blame-palette")] - pub blame_palette: Option<String>, + #[structopt(long = "blame-palette", default_value = "#FFFFFF #DDDDDD #BBBBBB")] + pub blame_palette: String, /// Format of `git blame` timestamp in raw git output received by delta. #[structopt( diff --git a/src/config.rs b/src/config.rs index 71580ddb..326153b2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -22,7 +22,7 @@ pub struct Config { pub available_terminal_width: usize, pub background_color_extends_to_terminal_width: bool, pub blame_format: String, - pub blame_palette: Option<Vec<String>>, + pub blame_palette: Vec<String>, pub blame_timestamp_format: String, pub commit_style: Style, pub color_only: bool, @@ -206,11 +206,11 @@ impl From<cli::Opt> for Config { .computed .background_color_extends_to_terminal_width, blame_format: opt.blame_format, - blame_palette: opt.blame_palette.map(|s| { - s.split_whitespace() - .map(|s| s.to_owned()) - .collect::<Vec<String>>() - }), + blame_palette: opt + .blame_palette + .split_whitespace() + .map(|s| s.to_owned()) + .collect::<Vec<String>>(), blame_timestamp_format: opt.blame_timestamp_format, commit_style, color_only: opt.color_only, diff --git a/src/delta.rs b/src/delta.rs index 61dd475c..adec6823 100644 --- a/src/delta.rs +++ b/src/delta.rs @@ -485,13 +485,8 @@ impl<'a> StateMachine<'a> { color } else { let n_commits = self.blame_commit_colors.len(); - let n_colors = self.config.blame_palette.as_ref().map(|v| v.len()).unwrap(); - let new_color = self - .config - .blame_palette - .as_ref() - .map(|v| &v[(n_commits + 1) % n_colors]) - .unwrap(); + let n_colors = self.config.blame_palette.len(); + let new_color = &self.config.blame_palette[(n_commits + 1) % n_colors]; self.blame_commit_colors .insert(blame.commit.to_owned(), new_color.to_owned()); new_color |