From a42a651d0acd63f9a8eddc9530afabc4e47cb417 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Thu, 25 Aug 2022 17:41:21 +0200 Subject: [PATCH] Use color for $fish_color_valid_path if it exists This otherwise threw away the color. Since that's just information that is thrown away, let's just use it. Fixes #9159. --- doc_src/interactive.rst | 2 ++ src/highlight.cpp | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index 5081324da..94f118a6f 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -142,6 +142,8 @@ If a variable isn't set or is empty, fish usually tries ``$fish_color_normal``, - ``$fish_color_keyword``, where it tries ``$fish_color_command`` first. - ``$fish_color_option``, where it tries ``$fish_color_param`` first. +- For ``$fish_color_valid_path``, if that doesn't have a color, but only modifiers, it adds those to the color that would otherwise be used, + like ``$fish_color_param``. But if valid paths have a color, it uses that and adds in modifiers from the other color. .. _variables-color-pager: diff --git a/src/highlight.cpp b/src/highlight.cpp index b026af7c5..027756236 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -348,9 +348,18 @@ rgb_color_t highlight_color_resolver_t::resolve_spec_uncached(const highlight_sp auto var2 = vars.get(L"fish_color_valid_path"); if (var2) { rgb_color_t result2 = parse_color(*var2, is_background); - if (result.is_normal()) + if (result.is_normal()) { result = result2; - else { + } else if (!result2.is_normal()) { + // Valid path has an actual color, use it and merge the modifiers. + auto rescol = result2; + rescol.set_bold(result.is_bold() || result2.is_bold()); + rescol.set_underline(result.is_underline() || result2.is_underline()); + rescol.set_italics(result.is_italics() || result2.is_italics()); + rescol.set_dim(result.is_dim() || result2.is_dim()); + rescol.set_reverse(result.is_reverse() || result2.is_reverse()); + result = rescol; + } else { if (result2.is_bold()) result.set_bold(true); if (result2.is_underline()) result.set_underline(true); if (result2.is_italics()) result.set_italics(true);