improve table for lists

This commit is contained in:
JT 2021-09-25 20:58:02 +12:00
parent d1da75d315
commit a2996abd47
2 changed files with 9 additions and 5 deletions

View file

@ -74,10 +74,14 @@ fn convert_to_table(iter: impl IntoIterator<Item = Value>) -> Option<nu_table::T
let mut row = vec![row_num.to_string()];
for header in headers.iter().skip(1) {
let result = item.clone().follow_cell_path(&[PathMember::String {
val: header.into(),
span: Span::unknown(),
}]);
let result = if header == "<value>" {
Ok(item.clone())
} else {
item.clone().follow_cell_path(&[PathMember::String {
val: header.into(),
span: Span::unknown(),
}])
};
match result {
Ok(value) => row.push(value.into_string()),

View file

@ -290,7 +290,7 @@ impl Value {
pub fn columns(&self) -> Vec<String> {
match self {
Value::Record { cols, .. } => cols.clone(),
_ => vec![],
_ => vec!["<value>".into()],
}
}
}