Merge pull request #822 from jonathandturner/fix_707

Fix confusing unnamed column and crash
This commit is contained in:
Jonathan Turner 2019-10-14 18:46:37 +13:00 committed by GitHub
commit 473b6f727c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -60,11 +60,19 @@ pub fn get_column_path(
possible_matches.sort();
return Err(ShellError::labeled_error(
"Unknown column",
format!("did you mean '{}'?", possible_matches[0].1),
tag_for_tagged_list(path.iter().map(|p| p.tag())),
));
if possible_matches.len() > 0 {
return Err(ShellError::labeled_error(
"Unknown column",
format!("did you mean '{}'?", possible_matches[0].1),
tag_for_tagged_list(path.iter().map(|p| p.tag())),
));
} else {
return Err(ShellError::labeled_error(
"Unknown column",
"row does not contain this column",
tag_for_tagged_list(path.iter().map(|p| p.tag())),
));
}
}
}
}

View File

@ -42,7 +42,7 @@ impl TableView {
let mut headers = TableView::merge_descriptors(values);
if headers.len() == 0 {
headers.push("value".to_string());
headers.push("<unknown>".to_string());
}
let mut entries = vec![];