mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-13 21:52:37 +00:00
fix all spacing issues
This commit is contained in:
parent
7177c187da
commit
f1275b0e60
2 changed files with 19 additions and 18 deletions
|
@ -57,8 +57,8 @@ fn inner_display_one_line(
|
|||
group: detect_group_length(&metas),
|
||||
size: detect_size_lengths(&metas, &flags),
|
||||
date: detect_date_length(&metas, &flags),
|
||||
name: detect_name_length(&metas, &icons),
|
||||
name_with_symlink: detect_name_with_symlink_length(&metas, &icons),
|
||||
name: detect_name_length(&metas, &icons, &flags),
|
||||
name_with_symlink: detect_name_with_symlink_length(&metas, &icons, &flags),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -190,8 +190,8 @@ fn inner_display_tree(
|
|||
group: detect_group_length(&metas),
|
||||
size: detect_size_lengths(&metas, flags),
|
||||
date: detect_date_length(&metas, flags),
|
||||
name: detect_name_length(&metas, &icons),
|
||||
name_with_symlink: detect_name_with_symlink_length(&metas, &icons),
|
||||
name: detect_name_length(&metas, &icons, &flags),
|
||||
name_with_symlink: detect_name_with_symlink_length(&metas, &icons, &flags),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -301,10 +301,12 @@ fn get_long_output(
|
|||
Block::Name => {
|
||||
if flags.no_symlink {
|
||||
strings.push(meta.name.render(colors, icons));
|
||||
strings
|
||||
.push(ANSIString::from(" ".to_string().repeat(
|
||||
padding_rules.name - meta.name.name_string(icons).len(),
|
||||
)))
|
||||
strings.push(meta.indicator.render(&flags));
|
||||
strings.push(ANSIString::from(" ".to_string().repeat(
|
||||
padding_rules.name
|
||||
- meta.indicator.len(&flags)
|
||||
- meta.name.name_string(icons).len(),
|
||||
)))
|
||||
} else {
|
||||
match meta.symlink.symlink_string() {
|
||||
Some(s) => {
|
||||
|
@ -313,6 +315,7 @@ fn get_long_output(
|
|||
strings.push(meta.symlink.render(colors));
|
||||
strings.push(ANSIString::from(" ".to_string().repeat(
|
||||
padding_rules.name_with_symlink
|
||||
- 3 // 3 = ( arrow + 2 spaces) for symlink;
|
||||
- meta.name.name_string(icons).len()
|
||||
- meta.indicator.len(&flags)
|
||||
- s.len(),
|
||||
|
@ -323,7 +326,7 @@ fn get_long_output(
|
|||
strings.push(meta.indicator.render(&flags));
|
||||
strings.push(meta.symlink.render(colors));
|
||||
strings.push(ANSIString::from(" ".to_string().repeat(
|
||||
padding_rules.name_with_symlink + 3
|
||||
padding_rules.name_with_symlink
|
||||
- meta.name.name_string(icons).len()
|
||||
- meta.indicator.len(&flags),
|
||||
)))
|
||||
|
@ -409,25 +412,26 @@ fn detect_size_lengths(metas: &[Meta], flags: &Flags) -> (usize, usize) {
|
|||
(max_value_length, max_unit_size)
|
||||
}
|
||||
|
||||
fn detect_name_length(metas: &[Meta], icons: &Icons) -> usize {
|
||||
fn detect_name_length(metas: &[Meta], icons: &Icons, flags: &Flags) -> usize {
|
||||
let mut max_value_length: usize = 0;
|
||||
|
||||
for meta in metas {
|
||||
if meta.name.name_string(&icons).len() > max_value_length {
|
||||
max_value_length = meta.name.name_string(&icons).len();
|
||||
let len = meta.name.name_string(&icons).len() + meta.indicator.len(&flags);
|
||||
if len > max_value_length {
|
||||
max_value_length = len;
|
||||
}
|
||||
}
|
||||
|
||||
max_value_length
|
||||
}
|
||||
|
||||
fn detect_name_with_symlink_length(metas: &[Meta], icons: &Icons) -> usize {
|
||||
fn detect_name_with_symlink_length(metas: &[Meta], icons: &Icons, flags: &Flags) -> usize {
|
||||
let mut max_value_length: usize = 0;
|
||||
|
||||
for meta in metas {
|
||||
let mut len = meta.name.name_string(&icons).len();
|
||||
let mut len = meta.name.name_string(&icons).len() + meta.indicator.len(&flags);
|
||||
if let Some(syml) = meta.symlink.symlink_string() {
|
||||
len += syml.len();
|
||||
len += syml.len() + 3 // 3 = ( arrow + 2 spaces) for symlink;
|
||||
}
|
||||
if len > max_value_length {
|
||||
max_value_length = len;
|
||||
|
|
|
@ -23,7 +23,6 @@ pub fn by_meta(a: &Meta, b: &Meta, flags: &Flags) -> Ordering {
|
|||
}
|
||||
|
||||
fn by_size(a: &Meta, b: &Meta, flags: &Flags) -> Ordering {
|
||||
|
||||
if flags.sort_order == SortOrder::Default {
|
||||
b.size.get_bytes().cmp(&a.size.get_bytes())
|
||||
} else {
|
||||
|
@ -31,8 +30,6 @@ fn by_size(a: &Meta, b: &Meta, flags: &Flags) -> Ordering {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn by_name(a: &Meta, b: &Meta, flags: &Flags) -> Ordering {
|
||||
if flags.sort_order == SortOrder::Default {
|
||||
a.name.cmp(&b.name)
|
||||
|
|
Loading…
Reference in a new issue