diff --git a/src/highlight/highlight.rs b/src/highlight/highlight.rs index a44f0bcd2..00d2727a1 100644 --- a/src/highlight/highlight.rs +++ b/src/highlight/highlight.rs @@ -42,9 +42,6 @@ impl HighlightSpec { pub fn new() -> Self { Self::default() } - pub fn with_fg(fg: HighlightRole) -> Self { - Self::with_fg_bg(fg, HighlightRole::normal) - } pub fn with_fg_bg(fg: HighlightRole, bg: HighlightRole) -> Self { Self { foreground: fg, @@ -52,9 +49,15 @@ pub fn with_fg_bg(fg: HighlightRole, bg: HighlightRole) -> Self { ..Default::default() } } + pub fn with_fg(fg: HighlightRole) -> Self { + Self::with_fg_bg(fg, HighlightRole::normal) + } pub fn with_bg(bg: HighlightRole) -> Self { Self::with_fg_bg(HighlightRole::normal, bg) } + pub fn with_both(role: HighlightRole) -> Self { + Self::with_fg_bg(role, role) + } } /// Given a string and list of colors of the same size, return the string with ANSI escape sequences diff --git a/src/pager.rs b/src/pager.rs index e529cf5d5..e20318ed4 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -293,10 +293,7 @@ fn completion_try_print( if !progress_text.is_empty() { let line = rendering.screen_data.add_line(); - let spec = HighlightSpec::with_fg_bg( - HighlightRole::pager_progress, - HighlightRole::pager_progress, - ); + let spec = HighlightSpec::with_both(HighlightRole::pager_progress); print_max( CharOffset::None, &progress_text, diff --git a/src/reader.rs b/src/reader.rs index 323530891..9a5eccae0 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1621,8 +1621,7 @@ fn paint_layout(&mut self, reason: &wstr, is_final_rendering: bool) { // Apply any selection. if let Some(selection) = data.selection { - let selection_color = - HighlightSpec::with_fg_bg(HighlightRole::selection, HighlightRole::selection); + let selection_color = HighlightSpec::with_both(HighlightRole::selection); let end = std::cmp::min(selection.stop, colors.len()); for color in &mut colors[selection.start.min(end)..end] { *color = selection_color; @@ -1637,10 +1636,7 @@ fn paint_layout(&mut self, reason: &wstr, is_final_rendering: bool) { pos..pos, vec![ if self.flash_autosuggestion { - HighlightSpec::with_fg_bg( - HighlightRole::search_match, - HighlightRole::search_match, - ) + HighlightSpec::with_both(HighlightRole::search_match) } else { HighlightSpec::with_fg(HighlightRole::autosuggestion) };