fix(strider): update out of range index in files (#1425)
This commit is contained in:
parent
48f2285e5b
commit
c5807767d2
3 changed files with 8 additions and 6 deletions
Binary file not shown.
|
|
@ -27,7 +27,7 @@ impl ZellijPlugin for State {
|
|||
}
|
||||
Key::Down | Key::Char('j') => {
|
||||
let next = self.selected().saturating_add(1);
|
||||
*self.selected_mut() = min(self.files.len() - 1, next);
|
||||
*self.selected_mut() = min(self.files.len().saturating_sub(1), next);
|
||||
}
|
||||
Key::Right | Key::Char('\n') | Key::Char('l') if !self.files.is_empty() => {
|
||||
self.traverse_dir_or_open_file();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ impl State {
|
|||
self.hide_hidden_files = !self.hide_hidden_files;
|
||||
}
|
||||
pub fn traverse_dir_or_open_file(&mut self) {
|
||||
match self.files[self.selected()].clone() {
|
||||
if let Some(f) = self.files.get(self.selected()) {
|
||||
match f.clone() {
|
||||
FsEntry::Dir(p, _) => {
|
||||
self.path = p;
|
||||
refresh_directory(self);
|
||||
|
|
@ -42,6 +43,7 @@ impl State {
|
|||
FsEntry::File(p, _) => open_file(p.strip_prefix(ROOT).unwrap()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue