mirror of
https://github.com/nushell/nushell
synced 2024-12-28 22:13:10 +00:00
Fix list printing (#540)
This commit is contained in:
parent
fc7ed1bfe4
commit
c3a16902fe
1 changed files with 21 additions and 14 deletions
|
@ -264,12 +264,18 @@ fn convert_to_table(
|
||||||
let mut row: Vec<(String, String)> =
|
let mut row: Vec<(String, String)> =
|
||||||
vec![("string".to_string(), (row_num + row_offset).to_string())];
|
vec![("string".to_string(), (row_num + row_offset).to_string())];
|
||||||
|
|
||||||
|
if headers.is_empty() {
|
||||||
|
// if header row is empty, this is probably a list so format it that way
|
||||||
|
row.push(("list".to_string(), item.into_abbreviated_string(config)))
|
||||||
|
} else {
|
||||||
for header in headers.iter().skip(1) {
|
for header in headers.iter().skip(1) {
|
||||||
let result = match item {
|
let result = match item {
|
||||||
Value::Record { .. } => item.clone().follow_cell_path(&[PathMember::String {
|
Value::Record { .. } => {
|
||||||
|
item.clone().follow_cell_path(&[PathMember::String {
|
||||||
val: header.into(),
|
val: header.into(),
|
||||||
span: head,
|
span: head,
|
||||||
}]),
|
}])
|
||||||
|
}
|
||||||
_ => Ok(item.clone()),
|
_ => Ok(item.clone()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -281,6 +287,7 @@ fn convert_to_table(
|
||||||
Err(_) => row.push(("empty".to_string(), "❎".into())),
|
Err(_) => row.push(("empty".to_string(), "❎".into())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data.push(row);
|
data.push(row);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue