Skip to content

Commit

Permalink
fix prev-activity and next-activity. fix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
thrombe committed Apr 29, 2024
1 parent 24c55ce commit 3fd4445
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl Command {
if *cycle {
i = (i + 1) % n;
} else {
i = (i + 1).min(n);
i = (i + 1).min(n - 1);
}
i
})
Expand Down Expand Up @@ -289,11 +289,11 @@ impl Command {
let new_activity_index = activity_index
.map(|i| {
let mut i = i;
let n = state.activities.len();
if cycle {
i += 1;
i %= state.activities.len();
i = (i + 1) % n;
} else {
i = i.min(state.activities.len() - 1);
i = (i + 1).min(n - 1);
}
i
})
Expand All @@ -316,11 +316,11 @@ impl Command {
let new_activity_index = activity_index
.map(|i| {
let mut i = i as isize;
let n = state.activities.len();
if cycle {
i += state.activities.len() as isize - 1;
i %= state.activities.len() as isize;
i = (n as isize + i - 1) % n as isize;
} else {
i = i.max(0);
i = (i - 1).max(0);
}
i as usize
})
Expand Down

0 comments on commit 3fd4445

Please sign in to comment.