lsd-rs / lsd

The next gen ls command
Apache License 2.0
13.54k stars 439 forks source link

theme: size none color is not respected #755

Open edshamis opened 2 years ago

edshamis commented 2 years ago

Expected behavior

I expect that size none color is for zero size objects.

Actual behavior

I added a theme, changed color for small size — worked. Changed color for none — don't see that color, color for zero size files is the same as for small ones.

meain commented 1 year ago

Color for none is not for 0 sized item, but rather things we don't display size for. This was originally used for folders for which we did not show size, but instead showed a -. However, we have since started showing size for them and thus making it obsolete. We can maybe consider repurposing it for 0 sized items.

edshamis commented 1 year ago

Ok, thanks for clarifying. I think distinct color for zero size is a good idea.

On Sun, Nov 27, 2022, 18:35 Abin Simon @.***> wrote:

Color for none is not for 0 sized item, but rather things we don't display size for. This was originally used for folders for which we did not show size, but instead showed a -. However, we have since started showing size for them and thus making it obsolete. We can maybe consider repurposing it for 0 sized items.

— Reply to this email directly, view it on GitHub https://github.com/Peltoche/lsd/issues/755#issuecomment-1328287693, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALNR4FQ4S6UKPHTAJBCG733WKOETNANCNFSM6AAAAAARHCRG7A . You are receiving this because you authored the thread.Message ID: @.***>

vlnx commented 1 year ago
index 9f39b99..74af321 100644
--- a/src/meta/size.rs
+++ b/src/meta/size.rs
@@ -89,7 +89,14 @@ impl Size {
     fn paint(&self, colors: &Colors, flags: &Flags, content: String) -> ColoredString {
         let unit = self.get_unit(flags);
         let elem = match unit {
-            Unit::Byte | Unit::Kilo => &Elem::FileSmall,
+            Unit::Byte => {
+                if self.bytes as f64 == 0.0 {
+                    &Elem::NonFile
+                } else {
+                    &Elem::FileSmall
+                }
+            }
+            Unit::Kilo => &Elem::FileSmall,
             Unit::Mega => &Elem::FileMedium,
             _ => &Elem::FileLarge,
         };