diff --git a/cli/src/tests/tree_test.rs b/cli/src/tests/tree_test.rs index f498c5fcfb..c0d45379f1 100644 --- a/cli/src/tests/tree_test.rs +++ b/cli/src/tests/tree_test.rs @@ -474,12 +474,12 @@ fn test_tree_cursor_child_for_point() { assert_eq!(c.node().kind(), "program"); // descend to expression statement - assert_eq!(c.goto_first_child_for_point(Point::new(6, 6)), Some(0)); + assert_eq!(c.goto_first_child_for_point(Point::new(6, 5)), Some(0)); assert_eq!(c.node().kind(), "expression_statement"); // step into ';' and back up assert_eq!(c.goto_first_child_for_point(Point::new(7, 0)), None); - assert_eq!(c.goto_first_child_for_point(Point::new(6, 6)), Some(1)); + assert_eq!(c.goto_first_child_for_point(Point::new(6, 5)), Some(1)); assert_eq!( (c.node().kind(), c.node().start_position()), (";", Point::new(6, 5)) @@ -516,7 +516,7 @@ fn test_tree_cursor_child_for_point() { assert!(c.goto_parent()); // step into first ',' and back up - assert_eq!(c.goto_first_child_for_point(Point::new(1, 12)), Some(2)); + assert_eq!(c.goto_first_child_for_point(Point::new(1, 11)), Some(2)); assert_eq!( (c.node().kind(), c.node().start_position()), (",", Point::new(1, 11)) diff --git a/lib/src/tree_cursor.c b/lib/src/tree_cursor.c index ddd7d66b5a..189a565905 100644 --- a/lib/src/tree_cursor.c +++ b/lib/src/tree_cursor.c @@ -274,7 +274,7 @@ static inline int64_t ts_tree_cursor_goto_first_child_for_byte_and_point( CursorChildIterator iterator = ts_tree_cursor_iterate_children(self); while (ts_tree_cursor_child_iterator_next(&iterator, &entry, &visible)) { Length entry_end = length_add(entry.position, ts_subtree_size(*entry.subtree)); - bool at_goal = entry_end.bytes >= goal_byte && point_gte(entry_end.extent, goal_point); + bool at_goal = entry_end.bytes > goal_byte && point_gt(entry_end.extent, goal_point); uint32_t visible_child_count = ts_subtree_visible_child_count(*entry.subtree); if (at_goal) { if (visible) {