Skip to content

Commit

Permalink
Prefer background colour when painting icons
Browse files Browse the repository at this point in the history
The rationale here is that there's more of a background colour than the foreground colour when painting text, and having a gap of no background colour in between the icon and the file name looks weird.

Fixes GH-561.
  • Loading branch information
ogham committed Oct 24, 2020
1 parent 67a6cdd commit 976db01
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/output/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ impl Icons {
}


/// Converts the style used to paint a file name into the style that should be
/// used to paint an icon.
///
/// - The background colour should be preferred to the foreground colour, as
/// if one is set, it’s the more “obvious” colour choice.
/// - If neither is set, just use the default style.
/// - Attributes such as bold or underline should not be used to paint the
/// icon, as they can make it look weird.
pub fn iconify_style<'a>(style: Style) -> Style {
style.foreground
style.background.or(style.foreground)
.map(Style::from)
.unwrap_or_default()
}
Expand Down

0 comments on commit 976db01

Please sign in to comment.