Skip to content

Commit

Permalink
fix: Bars in --skip-total flag
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bootandy committed Jan 26, 2025
1 parent 8e087e0 commit 6cbd736
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
};
Expand Down

0 comments on commit 6cbd736

Please sign in to comment.