fix: Bars in --skip-total flag

Before we calculated the % by taking the longest bar. If you use
--skip-total the longest bar is not the total. We need to sum up all the
children of root to work out what the largest size is.
This commit is contained in:
andy.boot
2025-01-25 23:05:29 +00:00
parent 9ba0b6d1d0
commit 73936a6d0c

View File

@@ -134,16 +134,8 @@ pub fn draw_it(
root_node: &DisplayNode,
skip_total: bool,
) {
let biggest = match skip_total {
false => root_node,
true => root_node
.get_children_from_node(false)
.next()
.unwrap_or(root_node),
};
let num_chars_needed_on_left_most = if idd.by_filecount {
let max_size = biggest.size;
let max_size = root_node.size;
max_size.separate_with_commas().chars().count()
} else if idd.by_filetime.is_some() {
FILETIME_SHOW_LENGTH
@@ -172,7 +164,7 @@ pub fn draw_it(
let display_data = DisplayData {
initial: idd,
num_chars_needed_on_left_most,
base_size: biggest.size,
base_size: root_node.size,
longest_string_length,
ls_colors: LsColors::from_env().unwrap_or_default(),
};