Allow queries with no patterns
This commit is contained in:
parent
c153711539
commit
4c17af3ecd
2 changed files with 11 additions and 3 deletions
|
|
@ -1029,6 +1029,16 @@ fn test_query_capture_names() {
|
|||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_query_with_no_patterns() {
|
||||
allocations::record(|| {
|
||||
let language = get_language("javascript");
|
||||
let query = Query::new(language, "").unwrap();
|
||||
assert!(query.capture_names().is_empty());
|
||||
assert_eq!(query.pattern_count(), 0);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_query_comments() {
|
||||
allocations::record(|| {
|
||||
|
|
|
|||
|
|
@ -789,7 +789,7 @@ TSQuery *ts_query_new(
|
|||
Stream stream = stream_new(source, source_len);
|
||||
stream_skip_whitespace(&stream);
|
||||
uint32_t start_step_index;
|
||||
for (;;) {
|
||||
while (stream.input < stream.end) {
|
||||
start_step_index = self->steps.size;
|
||||
uint32_t capture_count = 0;
|
||||
array_push(&self->start_bytes_by_pattern, stream.input - source);
|
||||
|
|
@ -824,8 +824,6 @@ TSQuery *ts_query_new(
|
|||
if (capture_count > self->max_capture_count) {
|
||||
self->max_capture_count = capture_count;
|
||||
}
|
||||
|
||||
if (stream.input == stream.end) break;
|
||||
}
|
||||
|
||||
ts_query__finalize_steps(self);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue