Skip to content

Commit

Permalink
fix: next/previous incorrect index (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanaden authored Jun 20, 2024
1 parent 2de8fea commit 31ce354
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rm-main/src/ui/components/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ impl<T: Clone> GenericTable<T> {
pub fn next(&mut self) {
let mut state = self.state.borrow_mut();
if let Some(curr) = state.selected() {
if curr == self.get_len() {
let last_idx = self.get_len() - 1;
if curr == last_idx {
state.select(Some(0));
} else {
state.select(Some(curr + 1));
Expand All @@ -52,8 +53,9 @@ impl<T: Clone> GenericTable<T> {
let mut state = self.state.borrow_mut();

if let Some(curr) = state.selected() {
let last_idx = self.get_len() - 1;
if curr == 0 {
state.select(Some(self.get_len()));
state.select(Some(last_idx));
} else {
state.select(Some(curr - 1));
}
Expand Down

0 comments on commit 31ce354

Please sign in to comment.