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') => {
|
Key::Down | Key::Char('j') => {
|
||||||
let next = self.selected().saturating_add(1);
|
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() => {
|
Key::Right | Key::Char('\n') | Key::Char('l') if !self.files.is_empty() => {
|
||||||
self.traverse_dir_or_open_file();
|
self.traverse_dir_or_open_file();
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ impl State {
|
||||||
self.hide_hidden_files = !self.hide_hidden_files;
|
self.hide_hidden_files = !self.hide_hidden_files;
|
||||||
}
|
}
|
||||||
pub fn traverse_dir_or_open_file(&mut self) {
|
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, _) => {
|
FsEntry::Dir(p, _) => {
|
||||||
self.path = p;
|
self.path = p;
|
||||||
refresh_directory(self);
|
refresh_directory(self);
|
||||||
|
|
@ -43,6 +44,7 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)]
|
||||||
pub enum FsEntry {
|
pub enum FsEntry {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue