mirror of
https://github.com/nushell/nushell
synced 2025-01-02 16:29:00 +00:00
Revert "improve table for lists"
This commit is contained in:
parent
04a8280d51
commit
75510b172a
1 changed files with 9 additions and 17 deletions
|
@ -66,30 +66,22 @@ fn convert_to_table(iter: impl IntoIterator<Item = Value>) -> Option<nu_table::T
|
||||||
|
|
||||||
if let Some(first) = iter.peek() {
|
if let Some(first) = iter.peek() {
|
||||||
let mut headers = first.columns();
|
let mut headers = first.columns();
|
||||||
if !headers.is_empty() {
|
headers.insert(0, "#".into());
|
||||||
headers.insert(0, "#".into());
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut data = vec![];
|
let mut data = vec![];
|
||||||
|
|
||||||
for (row_num, item) in iter.enumerate() {
|
for (row_num, item) in iter.enumerate() {
|
||||||
let mut row = vec![row_num.to_string()];
|
let mut row = vec![row_num.to_string()];
|
||||||
|
|
||||||
if headers.is_empty() {
|
for header in headers.iter().skip(1) {
|
||||||
row.push(item.into_string())
|
let result = item.clone().follow_cell_path(&[PathMember::String {
|
||||||
} else {
|
val: header.into(),
|
||||||
for header in headers.iter().skip(1) {
|
span: Span::unknown(),
|
||||||
let result = {
|
}]);
|
||||||
item.clone().follow_cell_path(&[PathMember::String {
|
|
||||||
val: header.into(),
|
|
||||||
span: Span::unknown(),
|
|
||||||
}])
|
|
||||||
};
|
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(value) => row.push(value.into_string()),
|
Ok(value) => row.push(value.into_string()),
|
||||||
Err(_) => row.push(String::new()),
|
Err(_) => row.push(String::new()),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue