Skip to content

Commit

Permalink
fix: panic on key up/down (ratatui-org#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzfrias committed Mar 20, 2023
1 parent 94197fa commit 61bc6da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit 61bc6da

Please sign in to comment.