fix: panic on key up/down (#16)

This commit is contained in:
Diego Frias
2023-03-20 09:26:51 -07:00
committed by GitHub
parent 94197fa1d1
commit 61bc6da821
+8 -2
View File
@@ -122,7 +122,10 @@ impl TreeState {
let new_index = current_index.map_or(0, |current_index| {
current_index.saturating_sub(1).min(visible.len() - 1)
});
let new_identifier = visible[new_index].identifier.clone();
let new_identifier = visible
.get(new_index)
.map(|o| o.identifier.clone())
.unwrap_or_default();
self.select(new_identifier);
}
@@ -137,7 +140,10 @@ impl TreeState {
let new_index = current_index.map_or(0, |current_index| {
current_index.saturating_add(1).min(visible.len() - 1)
});
let new_identifier = visible[new_index].identifier.clone();
let new_identifier = visible
.get(new_index)
.map(|o| o.identifier.clone())
.unwrap_or_default();
self.select(new_identifier);
}