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() {
|
while let Some(sel) = iter.peek() {
|
||||||
if sel != &&SelectorKind::Multiple {
|
if sel != &&SelectorKind::Multiple {
|
||||||
write!(f, ",")?;
|
write!(f, ",")?;
|
||||||
if sel != &&SelectorKind::Newline {
|
if sel == &&SelectorKind::Newline {
|
||||||
|
iter.next();
|
||||||
|
f.write_char('\n')?;
|
||||||
|
} else {
|
||||||
f.write_char(' ')?;
|
f.write_char(' ')?;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -65,6 +68,15 @@ impl Display for Selector {
|
|||||||
iter.next();
|
iter.next();
|
||||||
devour_whitespace(&mut iter);
|
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)?,
|
_ => write!(f, "{}", s)?,
|
||||||
}
|
}
|
||||||
|
@ -261,3 +261,8 @@ test!(
|
|||||||
"a,\nb {\n c {\n color: blue;\n }\n color: red;\n}\n",
|
"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"
|
"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