fix(lib): an empty root node should not precede an empty range

The problem is, given an empty file, the root node of this file spans 0
bytes. As such, the logic for determining whether or not the node
precedes the range fails, and is true when it should be false.
This commit is contained in:
Amaan Qureshi 2024-07-04 20:14:52 -04:00
parent 2bb20fe2fe
commit 6dd459b4ab
2 changed files with 30 additions and 6 deletions

View file

@ -5194,3 +5194,17 @@ fn test_query_wildcard_with_immediate_first_child() {
],
);
}
#[test]
fn test_query_on_empty_source_code() {
let language = get_language("javascript");
let source_code = "";
let query = r#"(program) @program"#;
let query = Query::new(&language, query).unwrap();
assert_query_matches(
&language,
&query,
source_code,
&[(0, vec![("program", "")])],
);
}