From 889488121a7c7afc7d43115014da8a31dee6e3f1 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 26 Jan 2020 19:16:26 -0500 Subject: [PATCH] Remove extra commas in selectors --- src/selector.rs | 11 +++++++++++ tests/main.rs | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/src/selector.rs b/src/selector.rs index 9cfe642..062de91 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -43,6 +43,17 @@ impl Display for Selector { } } } + SelectorKind::Multiple => { + devour_whitespace(&mut iter); + while let Some(sel) = iter.peek() { + if sel != &&SelectorKind::Multiple { + write!(f, ", ")?; + break; + } + iter.next(); + devour_whitespace(&mut iter); + } + } _ => write!(f, "{}", s)?, } } diff --git a/tests/main.rs b/tests/main.rs index a5b9e66..84dfeeb 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -309,6 +309,11 @@ mod test_selectors { "$x: oo, ba;\nf#{$x}r {\n baz {\n color: red;\n }\n}\n", "foo baz, bar baz {\n color: red;\n}\n" ); + test!( + extra_commas, + "div,, , span, ,, {\n color: red;\n}\n", + "div, span {\n color: red;\n}\n" + ); } #[cfg(test)]