diff --git a/lib/include/tree_sitter/api.h b/lib/include/tree_sitter/api.h index fad7a589..6f826604 100644 --- a/lib/include/tree_sitter/api.h +++ b/lib/include/tree_sitter/api.h @@ -801,16 +801,12 @@ void ts_query_cursor_exec(TSQueryCursor *, const TSQuery *, TSNode); * Manage the maximum number of in-progress matches allowed by this query * cursor. * - * Query cursors have a maximum capacity for storing lists of in-progress - * captures. If this capacity is exceeded, then the earliest-starting match will - * silently be dropped to make room for further matches. - * - * By default, this limit is 65,536 pending matches, which is effectively - * unlimited for most queries and syntax trees. You can optionally set this to a - * lower number if you want to have (and check) a tighter bound on query - * complexity. - * - * If you update the match limit, it must be > 0 and <= 65536. + * Query cursors have an optional maximum capacity for storing lists of + * in-progress captures. If this capacity is exceeded, then the + * earliest-starting match will silently be dropped to make room for further + * matches. This maximum capacity is optional — by default, query cursors allow + * any number of pending matches, dynamically allocating new space for them as + * needed as the query is executed. */ bool ts_query_cursor_did_exceed_match_limit(const TSQueryCursor *); uint32_t ts_query_cursor_match_limit(const TSQueryCursor *); diff --git a/lib/src/query.c b/lib/src/query.c index 2c8e7193..b082234f 100644 --- a/lib/src/query.c +++ b/lib/src/query.c @@ -152,10 +152,10 @@ typedef struct { */ typedef struct { uint32_t id; + uint32_t capture_list_id; uint16_t start_depth; uint16_t step_index; uint16_t pattern_index; - uint16_t capture_list_id; uint16_t consumed_capture_count: 12; bool seeking_immediate_match: 1; bool has_in_progress_alternatives: 1; @@ -183,7 +183,7 @@ typedef struct { // use. We reuse those existing-but-unused capture lists before trying to // allocate any new ones. We use an invalid value (UINT32_MAX) for a capture // list's length to indicate that it's not in use. - uint16_t free_capture_list_count; + uint32_t free_capture_list_count; } CaptureListPool; /* @@ -367,9 +367,7 @@ static CaptureListPool capture_list_pool_new(void) { return (CaptureListPool) { .list = array_new(), .empty_list = array_new(), - // The maximum maxmimum is 64K, since we use `uint16_t` as our capture list - // index type. - .max_capture_list_count = 65536, + .max_capture_list_count = UINT32_MAX, .free_capture_list_count = 0, }; } @@ -2318,7 +2316,7 @@ uint32_t ts_query_cursor_match_limit(const TSQueryCursor *self) { } void ts_query_cursor_set_match_limit(TSQueryCursor *self, uint32_t limit) { - assert(limit > 0 && limit <= 65536); + assert(limit > 0); self->capture_list_pool.max_capture_list_count = limit; }