Fix panic when deleting the last item

This commit is contained in:
kageru 2020-01-25 15:49:54 +01:00
parent dac7838293
commit 1428ced923
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

@ -71,7 +71,7 @@ impl TodoList {
return None;
}
let index = self.selected;
self.selected = index.min(self.todos.len() - 2);
self.selected = index.min(self.todos.len().saturating_sub(2));
return Some(self.todos.remove(index));
}