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

14
.gitignore vendored
View file

@ -1 +1,13 @@
/target
### Rust ###
# Generated by Cargo
# will have compiled files and executables
target/**
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# End of https://www.toptal.com/developers/gitignore/api/rust

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);