Fix: depth=0 bug for multiple arguments

https://github.com/bootandy/dust/issues/282
This commit is contained in:
andy.boot
2023-01-04 22:59:38 +00:00
parent c457a295b5
commit 07c228fd08
3 changed files with 17 additions and 10 deletions
+9 -2
View File
@@ -20,13 +20,20 @@ pub fn get_biggest(
let mut heap = BinaryHeap::new();
let number_top_level_nodes = top_level_nodes.len();
let root = get_new_root(top_level_nodes);
let mut allowed_nodes = HashSet::new();
allowed_nodes.insert(root.name.as_path());
heap = add_children(using_a_filter, min_size, only_dir, &root, depth, heap);
for _ in number_top_level_nodes..n {
if number_top_level_nodes > 1 {
heap = add_children(using_a_filter, min_size, only_dir, &root, usize::MAX, heap);
} else {
heap = add_children(using_a_filter, min_size, only_dir, &root, depth, heap);
}
let number_of_lines_in_output = n - number_top_level_nodes;
for _ in 0..number_of_lines_in_output {
let line = heap.pop();
match line {
Some(line) => {