diff --git a/Cargo.lock b/Cargo.lock index 001266d9..0599bd8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,7 +31,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "broot" -version = "0.5.1" +version = "0.5.2" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "custom_error 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 9dc96c66..09d63337 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "broot" -version = "0.5.1" +version = "0.5.2" authors = ["dystroy "] repository = "https://github.com/Canop/broot" description = "Fuzzy Search + tree + cd" diff --git a/src/fuzzy_patterns.rs b/src/fuzzy_patterns.rs index 29c7b840..08a03fea 100644 --- a/src/fuzzy_patterns.rs +++ b/src/fuzzy_patterns.rs @@ -2,7 +2,7 @@ //! It's not meant for file contents but for small strings (less than 1000 chars) //! such as file names. -use std::fmt; +use std::fmt::{self, Write}; use crate::patterns::{Match}; // weights used in match score computing @@ -21,8 +21,10 @@ pub struct FuzzyPattern { impl fmt::Display for FuzzyPattern { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // TODO is there a clean and efficient way to display a [char] ? - write!(f, "{}", self.lc_chars.iter().collect::()) + for &c in self.lc_chars.iter() { + f.write_char(c)? + } + Ok(()) } } diff --git a/src/main.rs b/src/main.rs index c2439815..67895a70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,7 +49,7 @@ use crate::external::Launchable; use crate::tree_options::TreeOptions; use crate::verbs::VerbStore; -const VERSION: &str = "0.5.1"; +const VERSION: &str = "0.5.2"; // declare the possible CLI arguments, and gets the values fn get_cli_args<'a>() -> clap::ArgMatches<'a> { diff --git a/src/tree_build.rs b/src/tree_build.rs index 625bbdd6..44f517d3 100644 --- a/src/tree_build.rs +++ b/src/tree_build.rs @@ -349,7 +349,7 @@ impl TreeBuilder { break; } if task_lifetime.is_expired() { - info!("task expired (core build)"); + info!("task expired (core build - outer loop)"); return None; } } else if nb_lines_ok >= self.targeted_size { @@ -374,6 +374,10 @@ impl TreeBuilder { break; } for next_level_dir_idx in &next_level_dirs { + if self.options.pattern.is_some() && task_lifetime.is_expired() { + info!("task expired (core build - inner loop)"); + return None; + } let has_child_match = self.load_children(*next_level_dir_idx); if has_child_match { // we must ensure the ancestors are made Ok @@ -486,7 +490,7 @@ impl TreeBuilder { // build a tree. Can be called only once per builder pub fn build(mut self, task_lifetime: &TaskLifetime) -> Option { - debug!("start building with pattern {:?}", self.options.pattern); + debug!("start building with pattern {}", self.options.pattern); match self.gather_lines(task_lifetime) { Some(out_blines) => { self.trim_excess(&out_blines);