diff --git a/src/highlight/highlight.rs b/src/highlight/highlight.rs index 587e64293..4090cf569 100644 --- a/src/highlight/highlight.rs +++ b/src/highlight/highlight.rs @@ -28,7 +28,7 @@ }; use crate::path::{path_as_implicit_cd, path_get_cdpath, path_get_path, paths_are_same_file}; use crate::terminal::Outputter; -use crate::text_face::{parse_text_face, TextFace, TextStyling}; +use crate::text_face::{parse_text_face, SpecifiedTextFace, TextFace, TextStyling}; use crate::threads::assert_is_background_thread; use crate::tokenizer::{variable_assignment_equals_pos, PipeOrRedir}; use crate::wchar::{wstr, WString, L}; @@ -177,21 +177,22 @@ pub(crate) fn parse_text_face_for_highlight( ) -> TextFace { let parse_var = |maybe_var: Option<&EnvVar>| { let Some(var) = maybe_var else { - return ( - Some(Color::Normal), - Some(Color::Normal), - TextStyling::default(), - ); + return SpecifiedTextFace { + fg: Some(Color::Normal), + bg: Some(Color::Normal), + style: TextStyling::default(), + }; }; parse_text_face(var.as_list()) }; - let (fg, _bg, mut style) = parse_var(fg_var); - let (_fg, bg, bg_style) = parse_var(bg_var); - let fg = fg.unwrap_or(Color::Normal); - let bg = bg.unwrap_or(Color::Normal); + let fg_face = parse_var(fg_var); + let bg_face = parse_var(bg_var); + let fg = fg_face.fg.unwrap_or(Color::Normal); + let bg = bg_face.bg.unwrap_or(Color::Normal); // In case the background role is different from the foreground one, we ignore its style // except for reverse mode. - style.reverse |= bg_style.reverse; + let mut style = fg_face.style; + style.reverse |= bg_face.style.reverse; TextFace { fg, bg, style } } diff --git a/src/reader.rs b/src/reader.rs index bccd23764..d95c3d331 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1660,10 +1660,7 @@ fn paint_layout(&mut self, reason: &wstr, is_final_rendering: bool) { let explicit_foreground = self .vars() .get_unless_empty(L!("fish_color_search_match")) - .is_some_and(|var| { - let (fg, _bg, _style) = parse_text_face(var.as_list()); - !fg.is_none() - }); + .is_some_and(|var| parse_text_face(var.as_list()).fg.is_some()); for color in &mut colors[range] { if explicit_foreground { diff --git a/src/text_face.rs b/src/text_face.rs index 26f7a4618..8220efbbb 100644 --- a/src/text_face.rs +++ b/src/text_face.rs @@ -96,9 +96,13 @@ pub fn new(fg: Color, bg: Color, style: TextStyling) -> Self { } } -pub(crate) fn parse_text_face( - arguments: &[WString], -) -> (Option, Option, TextStyling) { +pub(crate) struct SpecifiedTextFace { + pub(crate) fg: Option, + pub(crate) bg: Option, + pub(crate) style: TextStyling, +} + +pub(crate) fn parse_text_face(arguments: &[WString]) -> SpecifiedTextFace { let mut argv: Vec<&wstr> = Some(L!("")) .into_iter() .chain(arguments.iter().map(|s| s.as_utfstr())) @@ -124,7 +128,7 @@ pub(crate) fn parse_text_face( let bg = bgcolor.and_then(Color::from_wstr); assert!(fg.map_or(true, |fg| !fg.is_none())); assert!(bg.map_or(true, |bg| !bg.is_none())); - (fg, bg, style) + SpecifiedTextFace { fg, bg, style } } pub(crate) struct TextFaceArgsAndOptions<'a> {