diff --git a/src/builtin/list.rs b/src/builtin/list.rs index 2c9a8aa..e829851 100644 --- a/src/builtin/list.rs +++ b/src/builtin/list.rs @@ -147,10 +147,14 @@ 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 => (vec![v], ListSeparator::Space, Brackets::None), + v => { + is_first_list = false; + (vec![v], ListSeparator::Space, Brackets::None) + } }; let (list2, sep2) = match arg!(args, 1, "list2") { Value::List(v, sep, ..) => (v, sep), @@ -164,7 +168,7 @@ pub(crate) fn register(f: &mut HashMap) { ) { Value::Ident(s, ..) => match s.as_str() { "auto" => { - if list1.is_empty() { + if list1.is_empty() || !is_first_list { sep2 } else { sep1 diff --git a/tests/list.rs b/tests/list.rs index c5b91a5..ccf0b64 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -222,6 +222,11 @@ test!( "a {\n color: join((c: d, e: f), (g: h, i: j));\n}\n", "a {\n color: c d, e f, g h, i j;\n}\n" ); +test!( + join_non_list_first_takes_separator_of_second, + "a {\n color: join(c, (d, e));\n}\n", + "a {\n color: c, d, e;\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");