diff --git a/releases/zfsdu-linux-amd64 b/releases/zfsdu-linux-amd64 index c724551..ea89748 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 eeec2bd..e402a77 100644 --- a/src/app.rs +++ b/src/app.rs @@ -351,7 +351,7 @@ impl App { } pub fn is_marked(&self, name: &str) -> bool { - self.marked.contains(&name.to_string()) + self.marked.iter().any(|x| x == name) } pub fn delete_marked(&mut self) -> Result<()> { @@ -438,8 +438,9 @@ impl App { } pub fn cancel_input(&mut self) { + let was_search = self.input_mode == InputMode::Search; self.input_mode = InputMode::Normal; - if self.input_mode == InputMode::Search { + if was_search { self.search_query.clear(); self.search_matches.clear(); } @@ -585,13 +586,22 @@ impl App { } } - // 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) { - self.tree_items.get(real_idx).map(|ti| ti.parent_path.clone()) + // Get the scope parent: if cursor is on a dataset, use its full_name; + // if on a snapshot, use its parent_path (the owning dataset) + fn current_scope_parent(&self) -> Option { + if let Some(real_idx) = self.nth_visible(self.selected) { + self.tree_items.get(real_idx).map(|ti| match &ti.item { + ListItem::Dataset(d) => d.full_name.clone(), + ListItem::Snapshot(_) => ti.parent_path.clone(), + }) } else { None - }; + } + } + + // Select/Unselect Group (like MC) - works in current scope + pub fn select_group(&mut self) { + let current_parent = self.current_scope_parent(); let mut count = 0; for ti in &self.tree_items { @@ -614,11 +624,7 @@ impl App { } pub fn unselect_group(&mut self) { - let current_parent = if let Some(real_idx) = self.nth_visible(self.selected) { - self.tree_items.get(real_idx).map(|ti| ti.parent_path.clone()) - } else { - None - }; + let current_parent = self.current_scope_parent(); let visible_names: Vec = self.tree_items .iter() @@ -641,12 +647,7 @@ impl App { } pub fn invert_selection(&mut self) { - // Get current scope (parent dataset of selected item) - let current_parent = if let Some(real_idx) = self.nth_visible(self.selected) { - self.tree_items.get(real_idx).map(|ti| ti.parent_path.clone()) - } else { - None - }; + let current_parent = self.current_scope_parent(); let mut count = 0; for ti in &self.tree_items {