fix(lib): restrict pattern_map optimization when a wildcard step has an immediate first child

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
This commit is contained in:
Quentin LE DILAVREC 2024-07-05 09:35:24 +02:00 committed by GitHub
parent 9d1ac21392
commit 9610a84600
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -2740,7 +2740,7 @@ TSQuery *ts_query_new(
// there is a parent node, and capture it if necessary.
if (step->symbol == WILDCARD_SYMBOL && step->depth == 0 && !step->field) {
QueryStep *second_step = &self->steps.contents[start_step_index + 1];
if (second_step->symbol != WILDCARD_SYMBOL && second_step->depth == 1) {
if (second_step->symbol != WILDCARD_SYMBOL && second_step->depth == 1 && !second_step->is_immediate) {
wildcard_root_alternative_index = step->alternative_index;
start_step_index += 1;
step = second_step;