Skip to content

Commit 9705fd6

Browse files
committed
Fix prev_sibling indexing off-by-one
The patch f06a2c9 changed the code to use skip instead of nth, which lead to an off-by-one bug that was uncovered by unit tests in ludtwig, see [1]. [1]: MalteJanz/ludtwig#122 Fixes: #175
1 parent de36433 commit 9705fd6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cursor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl NodeData {
408408
let rev_siblings = self.green_siblings().enumerate().rev();
409409
let index = rev_siblings.len().checked_sub(self.index() as usize)?;
410410

411-
rev_siblings.skip(index + 1).find_map(|(index, child)| {
411+
rev_siblings.skip(index).find_map(|(index, child)| {
412412
child.as_ref().into_node().and_then(|green| {
413413
let parent = self.parent_node()?;
414414
let offset = parent.offset() + child.rel_offset();

0 commit comments

Comments
 (0)