mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
Fix view-source command (#4486)
This commit is contained in:
parent
f824388f63
commit
df07e8e410
@ -35,12 +35,16 @@ impl Command for ViewSource {
|
||||
let arg_span = arg.span()?;
|
||||
|
||||
match arg {
|
||||
Value::Block { span, .. } => {
|
||||
let contents = engine_state.get_span_contents(&span);
|
||||
Ok(
|
||||
Value::string(String::from_utf8_lossy(contents), call.head)
|
||||
.into_pipeline_data(),
|
||||
)
|
||||
Value::Block { val: block_id, .. } => {
|
||||
let block = engine_state.get_block(block_id);
|
||||
|
||||
if let Some(span) = block.span {
|
||||
let contents = engine_state.get_span_contents(&span);
|
||||
Ok(Value::string(String::from_utf8_lossy(contents), call.head)
|
||||
.into_pipeline_data())
|
||||
} else {
|
||||
Ok(Value::string("<internal command>", call.head).into_pipeline_data())
|
||||
}
|
||||
}
|
||||
Value::String { val, .. } => {
|
||||
if let Some(decl_id) = engine_state.find_decl(val.as_bytes()) {
|
||||
|
Loading…
Reference in New Issue
Block a user