diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index d33a7d8af..13bce0c0d 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -895,7 +895,7 @@ impl<'a> Tokenizer<'a> {
};
let mut location = state.location();
- while let Some(token) = self.next_token(&mut state)? {
+ while let Some(token) = self.next_token(&mut state, buf.last().map(|t| &t.token))? {
let span = location.span_to(state.location());
buf.push(TokenWithSpan { token, span });
@@ -932,7 +932,11 @@ impl<'a> Tokenizer<'a> {
}
/// Get the next token or return None
- fn next_token(&self, chars: &mut State) -> Result