Move from using a Block to an Arc'd Block (#3289)

This commit is contained in:
Jonathan Turner
2021-04-09 20:12:25 +12:00
committed by GitHub
parent ac070ae942
commit b791d1ab0d
11 changed files with 81 additions and 54 deletions

View File

@ -166,21 +166,23 @@ where
}
}
fn add_implicit_autoview(mut block: Block) -> Block {
if block.block.is_empty() {
let group = Group::new(
vec![{
let mut commands = Pipeline::new(block.span);
commands.push(ClassifiedCommand::Internal(InternalCommand::new(
"autoview".to_string(),
block.span,
block.span,
)));
commands
}],
block.span,
);
block.push(group);
fn add_implicit_autoview(mut block: Arc<Block>) -> Arc<Block> {
if let Some(block) = std::sync::Arc::<nu_protocol::hir::Block>::get_mut(&mut block) {
if block.block.is_empty() {
let group = Group::new(
vec![{
let mut commands = Pipeline::new(block.span);
commands.push(ClassifiedCommand::Internal(InternalCommand::new(
"autoview".to_string(),
block.span,
block.span,
)));
commands
}],
block.span,
);
block.push(group);
}
}
block
}

View File

@ -81,7 +81,9 @@ fn do_(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
x => x,
};
block.block.set_redirect(block_redirection);
if let Some(block) = std::sync::Arc::<nu_protocol::hir::Block>::get_mut(&mut block.block) {
block.set_redirect(block_redirection);
}
context.scope.enter_scope();
let result = run_block(&block.block, &context, input);
context.scope.exit_scope();

View File

@ -78,7 +78,9 @@ fn with_env(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
input,
) = raw_args.process()?;
block.block.set_redirect(redirection);
if let Some(block) = std::sync::Arc::<nu_protocol::hir::Block>::get_mut(&mut block.block) {
block.set_redirect(redirection);
}
let mut env = IndexMap::new();