# language: Support emitting multiple runnables from a single tree-sitter match \(\#57276\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/6396a9b4d34660dca19a09c8c33c70063d395eac)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 6396a9b4d34660dca19a09c8c33c70063d395eac

Requested commit: 6396a9b4d34660dca19a09c8c33c70063d395eac

Commit: 6396a9b4d34660dca19a09c8c33c70063d395eac

Tree: e553e48c64f8d6bc4f7bc7d9d474b7794c25ce46

Author: Smit Barmase

Committer: GitHub

## Message

```
language: Support emitting multiple runnables from a single tree-sitter match (#57276)

Sets up infra for fixing #46881. Follow-up to the approach discussed in
#36802 (comment).

The initial problem: Go table tests weren't being detected reliably in
larger files. The old approach created one tree-sitter match per table
row, which hit the cursor match limit (64) and caused rows to be
silently dropped.

The suggested fix was to use query repetition to capture all rows in a
single match, then post-process in Rust.

But this hit another problem: some captured rows aren't valid runnables
(e.g., when a struct has multiple string fields and the query can't tell
which one is the test name). Tree-sitter predicates can't validate
subsets of captures within a match, that logic needs to happen in Rust.

This PR adds a `RunnableResolver` trait that lets languages post-process
multi-capture matches. When a query uses `@_run_item` to mark item
boundaries, we split the captures into per-item groups and pass them to
the resolver. The resolver can then:

- Pick which `@run` to use: e.g., compare field names against
`t.Run(tc.name, ...)` to find the right string field.
- Return per-item extras: only the captures that correspond to the
chosen `@run`.

Release Notes:

- N/A
```

## Parents

- [6ac8385faf8f79f6c00b4904e39048b9d4f09da2](https://git.cafe/gitcafe/zed/commit/6ac8385faf8f79f6c00b4904e39048b9d4f09da2?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/6396a9b4d34660dca19a09c8c33c70063d395eac?format=markdown)
