Fix (most) table rendering issues in help example results

This commit is contained in:
NotTheDr01ds 2024-06-19 19:48:38 -04:00
parent 12991cd36f
commit 2fe005ce7b
2 changed files with 15 additions and 3 deletions

View File

@ -170,7 +170,10 @@ impl Command for Table {
}),
Value::test_record(record! {
"a" => Value::test_int(3),
"b" => Value::test_int(4),
"b" => Value::test_list(vec![
Value::test_int(4),
Value::test_int(4),
])
}),
])),
},

View File

@ -4,7 +4,7 @@ use nu_protocol::{
debugger::WithoutDebug,
engine::{Command, EngineState, Stack, UNKNOWN_SPAN_ID},
record, Category, Example, IntoPipelineData, PipelineData, Signature, Span, SpanId,
SyntaxShape, Type, Value,
SyntaxShape, Type, Value, Spanned
};
use std::{collections::HashMap, fmt::Write};
@ -296,6 +296,15 @@ fn get_documentation(
}
if let Some(result) = &example.result {
let mut table_expand_call = Call::new(Span::unknown());
table_expand_call.add_named((
Spanned {
item: "expand".to_string(),
span: Span::unknown()
},
None,
None,
));
let table = engine_state
.find_decl("table".as_bytes(), &[])
.and_then(|decl_id| {
@ -304,7 +313,7 @@ fn get_documentation(
.run(
engine_state,
stack,
&Call::new(Span::new(0, 0)),
&table_expand_call,
PipelineData::Value(result.clone(), None),
)
.ok()