mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-12 05:31:14 +02:00
Fix different inode number lengths
This commit is contained in:
parent
c1469a4196
commit
cd394c0feb
1 changed files with 5 additions and 10 deletions
|
@ -46,6 +46,8 @@ module ColorLS
|
|||
@git_status = init_git_status(show_git)
|
||||
@time_style = time_style
|
||||
@indicator_style = indicator_style
|
||||
# how much characters an item occupies besides its name
|
||||
@additional_chars_per_item = 12 + (@show_git ? 4 : 0) + (@show_inode ? 10 : 0)
|
||||
|
||||
init_colors colors
|
||||
|
||||
|
@ -151,15 +153,8 @@ module ColorLS
|
|||
end
|
||||
end
|
||||
|
||||
# how much characters an item occupies besides its name
|
||||
CHARS_PER_ITEM = 12
|
||||
|
||||
def additional_chars
|
||||
CHARS_PER_ITEM + (@show_git ? 4 : 0) + (@show_inode ? 10 : 0)
|
||||
end
|
||||
|
||||
def item_widths
|
||||
@contents.map { |item| Unicode::DisplayWidth.of(item.show) + additional_chars }
|
||||
@contents.map { |item| Unicode::DisplayWidth.of(item.show) + @additional_chars_per_item }
|
||||
end
|
||||
|
||||
def filter_hidden_contents
|
||||
|
@ -307,7 +302,7 @@ module ColorLS
|
|||
def inode(content)
|
||||
return '' unless @show_inode
|
||||
|
||||
content.stats.ino.to_s.colorize(@colors[:inode])
|
||||
content.stats.ino.to_s.rjust(10).colorize(@colors[:inode])
|
||||
end
|
||||
|
||||
def long_info(content)
|
||||
|
@ -358,7 +353,7 @@ module ColorLS
|
|||
entry = fetch_string(content, *options(content))
|
||||
line << (' ' * padding)
|
||||
line << ' ' << entry.encode(Encoding.default_external, undef: :replace)
|
||||
padding = widths[i] - Unicode::DisplayWidth.of(content.show) - additional_chars
|
||||
padding = widths[i] - Unicode::DisplayWidth.of(content.show) - @additional_chars_per_item
|
||||
end
|
||||
print line << "\n"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue