diff --git a/src/builtin/list.rs b/src/builtin/list.rs index e829851..192dc59 100644 --- a/src/builtin/list.rs +++ b/src/builtin/list.rs @@ -147,14 +147,10 @@ pub(crate) fn register(f: &mut HashMap) { "join".to_owned(), Box::new(|mut args, _| { max_args!(args, 4); - let mut is_first_list = true; let (mut list1, sep1, brackets) = match arg!(args, 0, "list1") { Value::List(v, sep, brackets) => (v, sep, brackets), Value::Map(m) => (m.entries(), ListSeparator::Comma, Brackets::None), - v => { - is_first_list = false; - (vec![v], ListSeparator::Space, Brackets::None) - } + v => (vec![v], ListSeparator::Space, Brackets::None), }; let (list2, sep2) = match arg!(args, 1, "list2") { Value::List(v, sep, ..) => (v, sep), @@ -168,7 +164,7 @@ pub(crate) fn register(f: &mut HashMap) { ) { Value::Ident(s, ..) => match s.as_str() { "auto" => { - if list1.is_empty() || !is_first_list { + if list1.is_empty() || (list1.len() == 1 && sep1 == ListSeparator::Space) { sep2 } else { sep1 diff --git a/tests/list.rs b/tests/list.rs index ccf0b64..4f28b28 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -227,6 +227,11 @@ test!( "a {\n color: join(c, (d, e));\n}\n", "a {\n color: c, d, e;\n}\n" ); +test!( + join_single_bracketed_first_takes_separator_of_second, + "a {\n color: join([a], (b, ));\n}\n", + "a {\n color: [a, b];\n}\n" +); test!(bracketed_ident, "a {\n color: [a];\n}\n"); test!(bracketed_space_list, "a {\n color: [a b];\n}\n"); test!(bracketed_comma_list, "a {\n color: [a, b];\n}\n");