Skip to content

Commit

Permalink
fix(state): disable rolling over index when it's out of bound in Stat…
Browse files Browse the repository at this point in the history
…efulList

Signed-off-by: Deep Panchal <deep302001@gmail.com>
  • Loading branch information
deepanchal committed Jul 2, 2024
1 parent bea45e1 commit 56075ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<T> StatefulList<T> {
let i = match self.state.selected() {
Some(i) => {
if i >= self.items.len() - 1 {
0
i
} else {
i + 1
}
Expand All @@ -36,7 +36,7 @@ impl<T> StatefulList<T> {
let i = match self.state.selected() {
Some(i) => {
if i == 0 {
self.items.len() - 1
i
} else {
i - 1
}
Expand Down

0 comments on commit 56075ba

Please sign in to comment.