Properly handle trailing commas combined with newlines
This commit is contained in:
parent
53861ccb0d
commit
023bc647bd
@ -57,7 +57,10 @@ impl Display for Selector {
|
||||
while let Some(sel) = iter.peek() {
|
||||
if sel != &&SelectorKind::Multiple {
|
||||
write!(f, ",")?;
|
||||
if sel != &&SelectorKind::Newline {
|
||||
if sel == &&SelectorKind::Newline {
|
||||
iter.next();
|
||||
f.write_char('\n')?;
|
||||
} else {
|
||||
f.write_char(' ')?;
|
||||
}
|
||||
break;
|
||||
@ -65,6 +68,15 @@ impl Display for Selector {
|
||||
iter.next();
|
||||
devour_whitespace(&mut iter);
|
||||
}
|
||||
while let Some(sel) = iter.peek() {
|
||||
if sel != &&SelectorKind::Multiple
|
||||
&& sel != &&SelectorKind::Newline
|
||||
&& !sel.is_whitespace()
|
||||
{
|
||||
break;
|
||||
}
|
||||
iter.next();
|
||||
}
|
||||
}
|
||||
_ => write!(f, "{}", s)?,
|
||||
}
|
||||
|
@ -261,3 +261,8 @@ test!(
|
||||
"a,\nb {\n c {\n color: blue;\n }\n color: red;\n}\n",
|
||||
"a,\nb {\n color: red;\n}\na c,\nb c {\n color: blue;\n}\n"
|
||||
);
|
||||
test!(
|
||||
trailing_comma_newline,
|
||||
"#foo #bar,,\n,#baz #boom, {a: b}",
|
||||
"#foo #bar,\n#baz #boom {\n a: b;\n}\n"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user