mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
Make it-expansion work when in a list (#1903)
This commit is contained in:
parent
49b0592e3c
commit
e2dabecc0b
@ -567,6 +567,14 @@ impl SpannedExpression {
|
|||||||
}
|
}
|
||||||
Expression::Variable(Variable::It(_)) => true,
|
Expression::Variable(Variable::It(_)) => true,
|
||||||
Expression::Path(path) => path.head.has_shallow_it_usage(),
|
Expression::Path(path) => path.head.has_shallow_it_usage(),
|
||||||
|
Expression::List(list) => {
|
||||||
|
for l in list {
|
||||||
|
if l.has_shallow_it_usage() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
Expression::Invocation(block) => {
|
Expression::Invocation(block) => {
|
||||||
for commands in block.block.iter() {
|
for commands in block.block.iter() {
|
||||||
for command in commands.list.iter() {
|
for command in commands.list.iter() {
|
||||||
|
@ -60,6 +60,18 @@ fn proper_it_expansion() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_expansion_of_list() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: ".",
|
||||||
|
r#"
|
||||||
|
echo "foo" | echo [bar $it] | to json
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "[\"bar\",\"foo\"]");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn argument_invocation() {
|
fn argument_invocation() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
|
Loading…
Reference in New Issue
Block a user