diff options
author | Pierre Peltier <pierre.peltier@adevinta.com> | 2019-11-04 11:54:01 +0100 |
---|---|---|
committer | Abin Simon <abinsimon10@gmail.com> | 2019-12-06 11:35:03 +0530 |
commit | e4342f86d1b9672e271a4a717c9a33c8826fab72 (patch) | |
tree | 42ec5c39bc42e13e9eb530067ab3966e886e02fd | |
parent | 2efce04b0aa3b3e2347958bdb4b081b161d6edc9 (diff) |
Remove the SizeUnit padding calculation
This padding calculation is not more required because the right padding
is handled by the term_grid package.
I hope be able to remove the left padding once I had push some changes
into the term_grid package.
-rw-r--r-- | src/display.rs | 14 | ||||
-rw-r--r-- | src/flags.rs | 2 |
2 files changed, 3 insertions, 13 deletions
diff --git a/src/display.rs b/src/display.rs index 5223306..ef51719 100644 --- a/src/display.rs +++ b/src/display.rs @@ -235,7 +235,6 @@ fn get_output<'a>( padding_rules[&Block::SizeValue], )), Block::SizeValue => strings.push(meta.size.render_value(colors, flags)), - Block::SizeUnit => strings.push(meta.size.render_unit(colors, flags)), Block::Date => strings.push(meta.date.render(colors, &flags)), Block::Name => { let s: String = if flags.no_symlink { @@ -277,34 +276,27 @@ fn get_visible_width(input: &str) -> usize { UnicodeWidthStr::width(input) - nb_invisible_char } -fn detect_size_lengths(metas: &[Meta], flags: &Flags) -> (usize, usize) { +fn detect_size_lengths(metas: &[Meta], flags: &Flags) -> usize { let mut max_value_length: usize = 0; - let mut max_unit_size: usize = 0; for meta in metas { let value_len = meta.size.value_string(flags).len(); - let unit_len = meta.size.unit_string(&flags).len(); if value_len > max_value_length { max_value_length = value_len; } - - if unit_len > max_unit_size { - max_unit_size = unit_len; - } } - (max_value_length, max_unit_size) + max_value_length } fn get_padding_rules(metas: &[Meta], flags: &Flags) -> HashMap<Block, usize> { let mut padding_rules: HashMap<Block, usize> = HashMap::new(); if flags.blocks.contains(&Block::Size) { - let (size_val, size_unit) = detect_size_lengths(&metas, &flags); + let size_val = detect_size_lengths(&metas, &flags); padding_rules.insert(Block::SizeValue, size_val); - padding_rules.insert(Block::SizeUnit, size_unit); } padding_rules diff --git a/src/flags.rs b/src/flags.rs index 57ddc59..fe327e8 100644 --- a/src/flags.rs +++ b/src/flags.rs @@ -202,7 +202,6 @@ pub enum Block { Group, Size, SizeValue, - SizeUnit, Date, Name, } @@ -215,7 +214,6 @@ impl<'a> From<&'a str> for Block { "group" => Block::Group, "size" => Block::Size, "size_value" => Block::SizeValue, - "size_unit" => Block::SizeUnit, "date" => Block::Date, "name" => Block::Name, _ => panic!("invalid \"time\" flag: {}", block), |