summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parse/incremental.rs1
-rw-r--r--src/parse/parser.rs16
-rw-r--r--src/parse/tokens.rs1
3 files changed, 4 insertions, 14 deletions
diff --git a/src/parse/incremental.rs b/src/parse/incremental.rs
index 1ee37a51..5cb016d2 100644
--- a/src/parse/incremental.rs
+++ b/src/parse/incremental.rs
@@ -623,6 +623,7 @@ mod tests {
test("x = y", 1 .. 1, " + y\n", 0 .. 10);
test("abc\n= a heading\njoke", 3 .. 4, "\nmore\n\n", 0 .. 21);
test("abc\n= a heading\njoke", 3 .. 4, "\nnot ", 0 .. 19);
+ test("#let x = (1, 2 + ; Five\r\n\r", 19..22, "2.", 18..22);
test("hey #myfriend", 4 .. 4, "\\", 0 .. 14);
test("hey #myfriend", 4 .. 4, "\\", 3 .. 6);
diff --git a/src/parse/parser.rs b/src/parse/parser.rs
index b31f69d3..f36155d5 100644
--- a/src/parse/parser.rs
+++ b/src/parse/parser.rs
@@ -282,12 +282,6 @@ impl<'s> Parser<'s> {
self.eat();
rescan = false;
} else if required {
- // FIXME The error has to be inserted before any space rolls
- // around because the rescan will set the cursor back in front
- // of the space and reconsume it. Supressing the rescan is not
- // an option since additional rescans (e.g. for statements) can
- // be triggered directly afterwards, without processing any
- // other token.
self.push_error(format_eco!("expected {}", end));
self.last_unterminated = Some(self.prev_end());
}
@@ -380,14 +374,8 @@ impl Parser<'_> {
/// Push an error into the children list.
pub fn push_error(&mut self, msg: impl Into<EcoString>) {
let error = NodeKind::Error(ErrorPos::Full, msg.into());
- for i in (0 .. self.children.len()).rev() {
- if Self::is_trivia_ext(self.children[i].kind(), false) {
- self.children.remove(i);
- } else {
- break;
- }
- }
- self.children.push(GreenData::new(error, 0).into());
+ let idx = self.trivia_start();
+ self.children.insert(idx.0, GreenData::new(error, 0).into());
}
/// Eat the current token and add an error that it is unexpected.
diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs
index 3a0ad1ad..7dfca2bf 100644
--- a/src/parse/tokens.rs
+++ b/src/parse/tokens.rs
@@ -727,6 +727,7 @@ mod tests {
t!(Both["a1/"]: " \n" => Space(1));
t!(Both["a1/"]: " \n " => Space(1));
t!(Both["a1/"]: "\r\n" => Space(1));
+ t!(Both["a1/"]: "\r\n\r" => Space(2));
t!(Both["a1/"]: " \n\t \n " => Space(2));
t!(Both["a1/"]: "\n\r" => Space(2));
t!(Both["a1/"]: " \r\r\n \x0D" => Space(3));