mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 03:44:19 +01:00
Light fixes (#2455)
* Add optional commas for items in lists and tables * A couple last fixes
This commit is contained in:
parent
abc05ece21
commit
df691c6c91
@ -142,8 +142,8 @@ impl PrettyDebug for FormatInlineShape {
|
|||||||
let (right, right_inclusion) = &range.to;
|
let (right, right_inclusion) = &range.to;
|
||||||
|
|
||||||
let op = match (left_inclusion, right_inclusion) {
|
let op = match (left_inclusion, right_inclusion) {
|
||||||
(RangeInclusion::Inclusive, RangeInclusion::Exclusive) => "..",
|
(RangeInclusion::Inclusive, RangeInclusion::Inclusive) => "..",
|
||||||
_ => unimplemented!("No syntax for ranges that aren't inclusive on the left and exclusive on the right")
|
_ => unimplemented!("No syntax for ranges that aren't inclusive on the left and inclusive on the right")
|
||||||
};
|
};
|
||||||
|
|
||||||
left.clone().format().pretty() + b::operator(op) + right.clone().format().pretty()
|
left.clone().format().pretty() + b::operator(op) + right.clone().format().pretty()
|
||||||
|
@ -610,6 +610,22 @@ impl SpannedExpression {
|
|||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
Expression::Table(headers, cells) => {
|
||||||
|
for l in headers {
|
||||||
|
if l.has_shallow_it_usage() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for row in cells {
|
||||||
|
for cell in row {
|
||||||
|
if cell.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() {
|
||||||
@ -646,6 +662,20 @@ impl SpannedExpression {
|
|||||||
item.expand_it_usage();
|
item.expand_it_usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SpannedExpression {
|
||||||
|
expr: Expression::Table(headers, cells),
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
for header in headers.iter_mut() {
|
||||||
|
header.expand_it_usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
for row in cells.iter_mut() {
|
||||||
|
for cell in row {
|
||||||
|
cell.expand_it_usage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
SpannedExpression {
|
SpannedExpression {
|
||||||
expr: Expression::Path(path),
|
expr: Expression::Path(path),
|
||||||
..
|
..
|
||||||
|
@ -454,6 +454,18 @@ fn list_with_commas() {
|
|||||||
assert_eq!(actual.out, "6");
|
assert_eq!(actual.out, "6");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_expansion_of_tables() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: ".",
|
||||||
|
r#"
|
||||||
|
echo foo | echo [[`foo {{$it}} bar`]; [`{{$it}} foo`]] | get "foo foo bar"
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "foo foo");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn table_with_commas() {
|
fn table_with_commas() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
|
Loading…
Reference in New Issue
Block a user