Fix crashes

This commit is contained in:
Dheepak Krishnamurthy 2020-07-27 00:36:11 -06:00
parent 75141ef561
commit b7b6a0f65c
2 changed files with 22 additions and 1 deletions

View file

@ -278,6 +278,9 @@ impl App {
self.export_headers();
}
pub fn next(&mut self) {
if self.tasks.len() == 0 {
return
}
let i = match self.state.selected() {
Some(i) => {
if i >= self.tasks.len() - 1 {
@ -291,6 +294,9 @@ impl App {
self.state.select(Some(i));
}
pub fn previous(&mut self) {
if self.tasks.len() == 0 {
return
}
let i = match self.state.selected() {
Some(i) => {
if i == 0 {
@ -344,6 +350,7 @@ impl App {
pub fn export_tasks(&mut self) {
let mut task = Command::new("task");
task.arg("rc.json.array=on");
task.arg("export");
match split(&self.filter) {
@ -417,6 +424,8 @@ mod tests {
let mut app = App::new();
app.update();
println!("{:?}", app.tasks);
println!("{:?}", app.task_report_columns);
println!("{:?}", app.task_report_labels);