# Account for greedy tree-sitter bracket matches \(\#43607\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 54309f4a4823ea1db344e3e48a28fd2687e310bb

Requested commit: 54309f4a4823ea1db344e3e48a28fd2687e310bb

Commit: 54309f4a4823ea1db344e3e48a28fd2687e310bb

Tree: 2cdeee4b60d969c13e5d6b74f4c4851d192c94ba

Author: Kirill Bulatov

Committer: GitHub

## Message

```
Account for greedy tree-sitter bracket matches (#43607)

Current approach is to colorize brackets based on their depth, which was
broken for markdown:

<img width="388" height="50" alt="image"
src="https://github.com/user-attachments/assets/bd8b6c2f-5a26-4d6b-a301-88675bf05920"
/>

Markdown grammar, for bracket queries
https://github.com/zed-industries/zed/blob/00e93bfa113a3daed6e4a97a7244ad04d58453ee/crates/languages/src/markdown/brackets.scm#L1-L8

and markdown document `[LLM-powered features](./ai/overview.md), [bring
and configure your own API
keys](./ai/llm-providers.md#use-your-own-keys)`, matches first bracket
(offset 0) with two different ones:

* `[LLM-powered features]`

* `[LLM-powered features](./ai/overview.md), [bring and configure your
own API keys]`

which mix and add different color markers.

Now, in case multiple pairs exist for the same first bracket, Zed will
only colorize the shortest one:
<img width="373" height="33" alt="image"
src="https://github.com/user-attachments/assets/04b3f7af-8927-4a8b-8f52-de8b5bb063ac"
/>


Release Notes:

- Fixed bracket colorization mixing colors in markdown files
```

## Parents

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

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