Fix next_page selection calculation

This fixes an issue with the current_selection overflowing plus keeps
the behavior consistent with prev_page.
This commit is contained in:
Abin Simon 2021-04-07 10:07:09 +05:30
parent b732b62e7b
commit 5d8c8356f4

View file

@ -1187,16 +1187,19 @@ impl TaskwarriorTuiApp {
return;
}
let i = {
if self.current_selection >= self.tasks.len() - 1 {
if self.current_selection == self.tasks.len() - 1 {
if self.config.uda_task_report_looping {
0
} else {
self.current_selection
self.tasks.len() - 1
}
} else {
self.current_selection
.checked_add(self.task_report_height as usize)
.unwrap_or_else(|| self.tasks.len())
std::cmp::min(
self.current_selection
.checked_add(self.task_report_height as usize)
.unwrap_or_else(|| self.tasks.len() - 1),
self.tasks.len() - 1,
)
}
};
self.current_selection = i;