Skip to content

Commit

Permalink
Set select_focus when selecting by name or path
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Feb 6, 2025
1 parent f823d17 commit 06b8132
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1844,20 +1844,26 @@ impl Tab {
}

pub fn select_name(&mut self, name: &str) {
self.select_focus = None;
if let Some(ref mut items) = self.items_opt {
for item in items.iter_mut() {
for (i, item) in items.iter_mut().enumerate() {
item.selected = item.name == name;
if item.selected {
self.select_focus = Some(i);
}
}
}
}

pub fn select_paths(&mut self, paths: Vec<PathBuf>) {
self.select_focus = None;
if let Some(ref mut items) = self.items_opt {
for item in items.iter_mut() {
for (i, item) in items.iter_mut().enumerate() {
item.selected = false;
if let Some(path) = item.path_opt() {
if paths.contains(path) {
item.selected = true;
self.select_focus = Some(i);
}
}
}
Expand Down

0 comments on commit 06b8132

Please sign in to comment.