Fix cancel_input bug, scope selection on datasets, is_marked perf
- cancel_input: mode was set to Normal before checking if Search, so search query was never cleared on Esc - select_group/unselect_group/invert: use dataset full_name as scope when cursor is on a dataset (previously used parent_path which matched nothing) - is_marked: avoid unnecessary String allocation per comparison
This commit is contained in:
parent
bddd44f3ca
commit
24960398db
Binary file not shown.
37
src/app.rs
37
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<String> {
|
||||
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<String> = 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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user