diff --git a/Cargo.toml b/Cargo.toml index 9da70ea..8e4bf19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zfsdu" -version = "0.2.1" +version = "0.2.2" edition = "2021" description = "ncdu-like disk usage viewer for ZFS with snapshot management" authors = ["Florian Schermer"] diff --git a/releases/zfsdu-linux-amd64 b/releases/zfsdu-linux-amd64 index 21dba10..c724551 100644 Binary files a/releases/zfsdu-linux-amd64 and b/releases/zfsdu-linux-amd64 differ diff --git a/src/app.rs b/src/app.rs index eb5f466..eeec2bd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -212,6 +212,7 @@ impl App { pub fn rebuild_tree(&mut self) { self.tree_items = Self::build_tree_view(&self.root_entries, 0, &[], &self.expanded, ""); self.apply_filter(); + self.refresh_search_matches(); self.ensure_valid_selection(); } @@ -561,6 +562,29 @@ impl App { self.search_matches.contains(&real_index) } + fn refresh_search_matches(&mut self) { + if self.search_query.is_empty() { + return; + } + self.search_matches.clear(); + let query = self.search_query.to_lowercase(); + for (i, tree_item) in self.tree_items.iter().enumerate() { + if tree_item.visible { + let name = tree_item.item.full_name().to_lowercase(); + if name.contains(&query) { + self.search_matches.push(i); + } + } + } + if !self.search_matches.is_empty() { + if self.current_match >= self.search_matches.len() { + self.current_match = self.search_matches.len() - 1; + } + } else { + self.current_match = 0; + } + } + // Select/Unselect Group (like MC) - works in current scope pub fn select_group(&mut self) { let current_parent = if let Some(real_idx) = self.nth_visible(self.selected) {