Просмотр исходного кода

Make icon styles appropriate for all file types

exa now bases the icon style for a file on its file name and kind in all cases, rather than just on its file name. This means that directories and symlinks have the correctly-coloured icon.

It also only takes the foreground colour into account while styling the icon, to make sure they're not bold or underlined.

Fixes GH-528.
Benjamin Sago 5 лет назад
Родитель
Сommit
67a6cdd46a
2 измененных файлов с 4 добавлено и 14 удалено
  1. 1 1
      src/output/file_name.rs
  2. 3 13
      src/output/icons.rs

+ 1 - 1
src/output/file_name.rs

@@ -113,7 +113,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
         let mut bits = Vec::new();
         let mut bits = Vec::new();
 
 
         if self.options.icons {
         if self.options.icons {
-            let style = iconify_style(self.colours.colour_file(self.file));
+            let style = iconify_style(self.style());
             let file_icon = icon_for_file(self.file).to_string();
             let file_icon = icon_for_file(self.file).to_string();
 
 
             bits.push(style.paint(file_icon));
             bits.push(style.paint(file_icon));

+ 3 - 13
src/output/icons.rs

@@ -28,19 +28,9 @@ impl Icons {
 
 
 
 
 pub fn iconify_style<'a>(style: Style) -> Style {
 pub fn iconify_style<'a>(style: Style) -> Style {
-    if style.is_underline {
-        match style.foreground {
-            Some(color) => {
-                Style::from(color)
-            }
-            None => {
-                Style::default()
-            }
-        }
-    }
-    else {
-        style
-    }
+    style.foreground
+         .map(Style::from)
+         .unwrap_or_default()
 }
 }