parse selectors that grow larger from interpolation

This commit is contained in:
ConnorSkees 2020-05-16 17:28:30 -04:00
parent 2db3398fe2
commit 2d0a9abb13
2 changed files with 9 additions and 7 deletions

View File

@ -285,13 +285,7 @@ impl Selector {
let mut sel_toks = Vec::new();
let mut current_pos = 0;
sel_toks.extend(string.chars().map(|x| {
let len = x.len_utf8() as u64;
let tok = Token::new(span.subspan(current_pos, current_pos + len), x);
current_pos += len;
tok
}));
sel_toks.extend(string.chars().map(|x| Token::new(span, x)));
let mut iter = sel_toks.into_iter().peekmore();

View File

@ -512,3 +512,11 @@ test!(
"\\61 {\n color: red;\n}\n",
"a {\n color: red;\n}\n"
);
/// this checks for a bug in which the selector
/// contents get longer as a result of interpolation,
/// which interferes with span information.
test!(
selector_span_gets_larger,
"$a: aaaaaaaaaaa;\n\n#{$a} {\n color: foo;\n}\n",
"aaaaaaaaaaa {\n color: foo;\n}\n"
);