summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2019-03-08 16:28:35 +0100
committerCanop <cano.petrole@gmail.com>2019-03-08 16:28:35 +0100
commit2b93c0c67569c6117f669ab78d8a2ec420e450c5 (patch)
tree61bed8e103608f2b36a724d4bad136b372fd24a3
parent8bb38ccb983736ead39ef43024e11eb36ebdc1b2 (diff)
fix a few problems with the unlisted count
-rw-r--r--.gitignore1
-rw-r--r--CHANGELOG.md4
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/flat_tree.rs3
-rw-r--r--src/tree_build.rs13
6 files changed, 18 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index 6d55335..2da0732 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+com
bench.sh
dev.log
deploy.sh
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cd868a8..da3127f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+<a name="v0.7.1"></a>
+### v0.7.1 - 2019-03-08
+- fix a few problems with the count of "unlisted" files
+
<a name="v0.7.0"></a>
### v0.7.0 - 2019-03-07
##### Major changes
diff --git a/Cargo.lock b/Cargo.lock
index 6a896a0..b9c49a2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -39,7 +39,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "broot"
-version = "0.7.0"
+version = "0.7.1"
dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index be1e799..a1501c6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "broot"
-version = "0.7.0"
+version = "0.7.1"
authors = ["dystroy <denys.seguret@gmail.com>"]
repository = "https://github.com/Canop/broot"
description = "Fuzzy Search + tree + cd"
diff --git a/src/flat_tree.rs b/src/flat_tree.rs
index 3b98801..0686dde 100644
--- a/src/flat_tree.rs
+++ b/src/flat_tree.rs
@@ -29,6 +29,7 @@ pub struct TreeLine {
pub path: PathBuf,
pub line_type: LineType,
pub has_error: bool,
+ pub nb_kept_children: usize,
pub unlisted: usize, // number of not listed children (Dir) or brothers (Pruning)
pub score: i32, // 0 if there's no pattern
pub size: Option<Size>, // None when not measured
@@ -201,7 +202,7 @@ impl Tree {
if parent_index != last_parent_index {
// the line at end_index is the last listed child of the line at parent_index
let unlisted = self.lines[parent_index].unlisted;
- if unlisted > 0 {
+ if unlisted > 0 && self.lines[end_index].nb_kept_children == 0 {
self.lines[end_index].line_type = LineType::Pruning;
self.lines[end_index].unlisted = unlisted + 1;
self.lines[parent_index].unlisted = 0;
diff --git a/src/tree_build.rs b/src/tree_build.rs
index 54fd7f4..d0faa9b 100644
--- a/src/tree_build.rs
+++ b/src/tree_build.rs
@@ -182,11 +182,14 @@ impl BLine {
LineType::File
};
let unlisted = if let Some(children) = &self.children {
- children.len() - (self.nb_kept_children as usize)
+ //debug!(
+ // "{:?} children.len()={} nb_kept_children={}",
+ // &self.path, children.len(), self.nb_kept_children
+ //);
+ children.len() - self.next_child_idx
} else {
0
};
- //debug!("unlisted in {:?} : {}", &self.path, unlisted);
TreeLine {
left_branchs: vec![false; self.depth as usize].into_boxed_slice(),
depth: self.depth,
@@ -194,6 +197,7 @@ impl BLine {
path: self.path.clone(),
line_type,
has_error,
+ nb_kept_children: self.nb_kept_children as usize,
unlisted,
score: self.score,
mode,
@@ -435,7 +439,7 @@ impl TreeBuilder {
if bline.has_match && bline.nb_kept_children == 0 && (bline.depth > 1 || trim_root)
// keep the complete first level when showing sizes
{
- //debug!("in list: {:?} score: {}", &bline.path, bline.score);
+ debug!("in list: {:?} score: {}", &bline.path, bline.score);
remove_queue.push(SortableBLineIdx {
idx: *idx,
score: bline.score,
@@ -448,11 +452,12 @@ impl TreeBuilder {
);
while count > self.targeted_size {
if let Some(sli) = remove_queue.pop() {
- //debug!("removing {:?}", &self.blines[sli.idx].path);
+ debug!("removing {:?}", &self.blines[sli.idx].path);
self.blines[sli.idx].has_match = false;
let parent_idx = self.blines[sli.idx].parent_idx;
let mut parent = &mut self.blines[parent_idx];
parent.nb_kept_children -= 1;
+ parent.next_child_idx -= 1; // to fix the number of "unlisted"
if parent.nb_kept_children == 0 {
remove_queue.push(SortableBLineIdx {
idx: parent_idx,