improve inspect output for arglists with 1 arg

This commit is contained in:
Connor Skees 2020-07-06 21:41:48 -04:00
parent ba7a368684
commit 7971bfe98b
3 changed files with 20 additions and 1 deletions

View File

@ -291,6 +291,14 @@ impl Value {
)),
Value::Dimension(num, unit) => Cow::owned(format!("{}{}", num, unit)),
Value::ArgList(args) if args.is_empty() => Cow::const_str("()"),
Value::ArgList(args) if args.len() == 1 => Cow::owned(format!(
"({},)",
args.iter()
.filter(|x| !x.is_null())
.map(|a| Ok(a.node.inspect(span)?))
.collect::<SassResult<Vec<Cow<'static, str>>>>()?
.join(", "),
)),
Value::ArgList(args) => Cow::owned(
args.iter()
.filter(|x| !x.is_null())

View File

@ -62,3 +62,14 @@ test!(
}",
"a {\n color: null;\n}\n"
);
test!(
inspect_arglist_with_one_arg,
"@function foo($a...) {
@return inspect($a);
}
a {
color: inspect(foo(1));
}",
"a {\n color: (1,);\n}\n"
);

View File

@ -129,5 +129,5 @@ test!(
a {
color: foo((a: b));
}",
"a {\n color: (a: b);\n}\n"
"a {\n color: ((a: b),);\n}\n"
);