# editor: Fix diagnostic rendering when semantic tokens set to full \(\#53008\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 3ed1c32bf9a1ebb485e3da6cabc8b3c0a423beea

Requested commit: 3ed1c32bf9a1ebb485e3da6cabc8b3c0a423beea

Commit: 3ed1c32bf9a1ebb485e3da6cabc8b3c0a423beea

Tree: 494a1bd5438ce107b692f4c031481976e392ce2f

Author: Xin Zhao

Committer: GitHub

## Message

```
editor: Fix diagnostic rendering when semantic tokens set to full (#53008)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #50212

There are two unreasonable coupling account for this issue, the coupling
of `use_tree_sitter` with `languge_aware` in

https://github.com/zed-industries/zed/blob/7892b932795911516f26f3c1c1c72249ed181ba8/crates/editor/src/element.rs#L3820-L3822
and the coupling of `language_aware` with `diagnostics` in
https://github.com/zed-industries/zed/blob/7892b932795911516f26f3c1c1c72249ed181ba8/crates/language/src/buffer.rs#L3736-L3746

Because of these couplings, when the editor stops using Tree-sitter
highlighting when `"semantic_tokens"` set to `"full"`, it also
accidentally stops fetching diagnostic information. This is why error
and warning underlines disappear.

I’ve fixed this by adding a separate `use_tree_sitter` parameter to
`highlighted_chunks`. This way, we can keep `language_aware` true to get
the diagnostic data we need, but still decide whether or not to apply
Tree-sitter highlights. I chose to fix this at the `highlighted_chunks`
level because I’m worried that changing the logic in the deeper layers
of the DisplayMap or Buffer might have too many side effects that are
hard to predict. This approach feels like a safer way to solve the
problem.

Release Notes:

- Fixed a bug where diagnostic underlines disappeared when
"semantic_tokens" set to "full"

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
```

## Parents

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

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