Skip to content

Commit

Permalink
round the pretty file size
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushpoddar committed Jul 31, 2024
1 parent cc659b6 commit b6342c3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/colorls/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,21 @@ def chars_for_size
end

def justify_size_info(size)
size_num = size[0][0..-4].rjust(chars_for_size, ' ')
size_num = displayable_size_num(size[0]).rjust(chars_for_size, ' ')
size_unit = @show_human_readable_size ? size[1].ljust(3, ' ') : size[1]
"#{size_num} #{size_unit}"
end

def displayable_size_num(size_num_str)
digit_after_decimal = size_num_str[-2]
if %w[5 6 7 8 9].include?(digit_after_decimal)
num = size_num_str.to_i
return (num + 1).to_s
end

size_num_str[0..-4]
end

def clear_chars_for_size
@chars_for_size = nil
end
Expand Down

0 comments on commit b6342c3

Please sign in to comment.