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:
parent
2bb20fe2fe
commit
6dd459b4ab
2 changed files with 30 additions and 6 deletions
|
|
@ -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", "")])],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue