Skip to content

Commit

Permalink
fix time column alignment issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-ward committed Jan 3, 2025
1 parent 216f745 commit fca8455
Showing 1 changed file with 39 additions and 13 deletions.
52 changes: 39 additions & 13 deletions lsv/format_long.v
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,44 @@ fn format_long_listing(entries []Entry, options Options) {

fn longest_entries(entries []Entry, options Options) Longest {
return Longest{
// vfmt off
inode: longest_inode_len(entries, inode_title, options)
nlink: longest_nlink_len(entries, links_title, options)
owner_name: longest_owner_name_len(entries, owner_title, options)
group_name: longest_group_name_len(entries, group_title, options)
size: longest_size_len(entries, size_title, options)
checksum: longest_checksum_len(entries, options.checksum, options)
file: longest_file_name_len(entries, name_title, options)
mtime: if !options.no_date { longest_time(entries, .modified, date_modified_title, options ) } else { 0 }
atime: if options.accessed_date { longest_time(entries, .accessed, date_accessed_title, options ) } else { 0 }
ctime: if options.changed_date { longest_time(entries, .changed, date_status_title, options ) } else { 0 }
// vfmt on
inode: if options.inode { longest_inode_len(entries, inode_title, options) } else { 0 }
nlink: if !options.no_hard_links {
longest_nlink_len(entries, links_title, options)
} else {
0
}
owner_name: if !options.no_owner_name {
longest_owner_name_len(entries, owner_title, options)
} else {
0
}
group_name: if !options.no_group_name {
longest_group_name_len(entries, group_title, options)
} else {
0
}
size: if !options.no_size { longest_size_len(entries, size_title, options) } else { 0 }
checksum: if options.checksum.len == 0 {
longest_checksum_len(entries, options.checksum, options)
} else {
0
}
file: longest_file_name_len(entries, name_title, options)
mtime: if !options.no_date {
longest_time(entries, .modified, date_modified_title, options)
} else {
0
}
atime: if options.accessed_date {
longest_time(entries, .accessed, date_accessed_title, options)
} else {
0
}
ctime: if options.changed_date {
longest_time(entries, .changed, date_status_title, options)
} else {
0
}
}
}

Expand Down Expand Up @@ -479,5 +505,5 @@ fn longest_time(entries []Entry, stat_time StatTime, title string, options Optio
names := entries.map(format_time(it, stat_time, options))
lengths := names.map(real_length(it))
max := arrays.max(lengths) or { 0 }
return max
return if options.header { max(real_length(title), max) } else { max }
}

0 comments on commit fca8455

Please sign in to comment.