summaryrefslogtreecommitdiff
path: root/src/parse/incremental.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-06-01 10:30:28 +0200
committerLaurenz <laurmaedje@gmail.com>2022-06-01 10:30:28 +0200
commitc56a8c41f0106fcf4bfa55a8b679e4f748b96caa (patch)
treeafa927171adbb6af42e42fc9c5d8d514f0017629 /src/parse/incremental.rs
parent0a9172cb1591565b4f5f44c333889ef24d351975 (diff)
Fix that incremental reparsing is impossible at the end
Co-Authored-By: Martin Haug <mhaug@live.de>
Diffstat (limited to 'src/parse/incremental.rs')
-rw-r--r--src/parse/incremental.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/parse/incremental.rs b/src/parse/incremental.rs
index e567cb07..3cafc014 100644
--- a/src/parse/incremental.rs
+++ b/src/parse/incremental.rs
@@ -68,6 +68,7 @@ impl Reparser<'_> {
for (i, child) in node.children().enumerate() {
let pos = NodePos { idx: i, offset };
let child_span = offset .. offset + child.len();
+ child_outermost = outermost && i + 1 == original_count;
match search {
SearchState::NoneFound => {
@@ -84,6 +85,11 @@ impl Reparser<'_> {
};
} else if child_span.contains(&self.replaced.start) {
search = SearchState::Inside(pos);
+ } else if child_span.end == self.replaced.start
+ && self.replaced.start == self.replaced.end
+ && child_outermost
+ {
+ search = SearchState::SpanFound(pos, pos);
} else {
// We look only for non spaces, non-semicolon and also
// reject text that points to the special case for URL
@@ -115,7 +121,6 @@ impl Reparser<'_> {
}
offset += child.len();
- child_outermost = outermost && i + 1 == original_count;
if search.done().is_some() {
break;
@@ -346,7 +351,7 @@ mod tests {
test("a\nb\nc *hel a b lo* d\nd\ne", 13..13, "c ", 6..20);
test("~~ {a} ~~", 4 .. 5, "b", 3 .. 6);
test("{(0, 1, 2)}", 5 .. 6, "11pt", 0..14);
- test("\n= A heading", 3 .. 3, "n evocative", 3 .. 23);
+ test("\n= A heading", 4 .. 4, "n evocative", 3 .. 23);
test("for~your~thing", 9 .. 9, "a", 4 .. 15);
test("a your thing a", 6 .. 7, "a", 0 .. 14);
test("{call(); abc}", 7 .. 7, "[]", 0 .. 15);