Merge pull request #67 from nushell/revert-65-list_table

Revert "improve table for lists"
This commit is contained in:
JT 2021-09-26 06:59:59 +13:00 committed by GitHub
commit 3421a8b58b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,30 +66,22 @@ fn convert_to_table(iter: impl IntoIterator<Item = Value>) -> Option<nu_table::T
if let Some(first) = iter.peek() {
let mut headers = first.columns();
if !headers.is_empty() {
headers.insert(0, "#".into());
}
headers.insert(0, "#".into());
let mut data = vec![];
for (row_num, item) in iter.enumerate() {
let mut row = vec![row_num.to_string()];
if headers.is_empty() {
row.push(item.into_string())
} else {
for header in headers.iter().skip(1) {
let result = {
item.clone().follow_cell_path(&[PathMember::String {
val: header.into(),
span: Span::unknown(),
}])
};
for header in headers.iter().skip(1) {
let result = item.clone().follow_cell_path(&[PathMember::String {
val: header.into(),
span: Span::unknown(),
}]);
match result {
Ok(value) => row.push(value.into_string()),
Err(_) => row.push(String::new()),
}
match result {
Ok(value) => row.push(value.into_string()),
Err(_) => row.push(String::new()),
}
}