Fully fix field underflow in go_to_previous_sibling (#4483)

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Max Brunsfeld 2025-06-02 15:34:25 -07:00 committed by GitHub
parent 52b719f8fb
commit 2ab9c9b590
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -388,7 +388,7 @@ fn test_tree_cursor_previous_sibling_with_aliases() {
.set_language(&get_test_fixture_language("aliases_in_root"))
.unwrap();
let text = "# comment\nfoo foo";
let text = "# comment\n# \nfoo foo";
let tree = parser.parse(text, None).unwrap();
let mut cursor = tree.walk();
assert_eq!(cursor.node().kind(), "document");
@ -396,12 +396,21 @@ fn test_tree_cursor_previous_sibling_with_aliases() {
cursor.goto_first_child();
assert_eq!(cursor.node().kind(), "comment");
assert!(cursor.goto_next_sibling());
assert_eq!(cursor.node().kind(), "comment");
assert!(cursor.goto_next_sibling());
assert_eq!(cursor.node().kind(), "bar");
assert!(cursor.goto_previous_sibling());
assert_eq!(cursor.node().kind(), "comment");
assert!(cursor.goto_previous_sibling());
assert_eq!(cursor.node().kind(), "comment");
assert!(cursor.goto_next_sibling());
assert_eq!(cursor.node().kind(), "comment");
assert!(cursor.goto_next_sibling());
assert_eq!(cursor.node().kind(), "bar");
}