# Escape control characters in syntax tree view \(\#59012\) · gitcafe/zed

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

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

Visibility: public

Requested revision: efa2987b8685c6a3c926365b9724f547be0270d1

Requested commit: efa2987b8685c6a3c926365b9724f547be0270d1

Commit: efa2987b8685c6a3c926365b9724f547be0270d1

Tree: c87ed3d5747db4c034e6a737645ecb8d78b7b464

Author: Konstantinos St

Committer: GitHub

## Message

```
Escape control characters in syntax tree view (#59012)

Escaping control characters so they correctly render in the syntax tree.
Note: the original issue debates whether "\n" should be printed at all.
It should if it's part of the grammar syntax. In the example posted
below, "\n" is printed because it's part of the c-preprocessor grammar,
but "\t" which is not, is not printed.
Note2: I've added an inline test since I saw that only bigger,
integration tests get their own file. Feel free to give guidance on the
topic.

Screenshots of before and after:
<img width="920" height="579" alt="Screenshot 2026-06-10 at 10 42 14"
src="https://github.com/user-attachments/assets/697b65d2-4ca3-4d9b-9cb9-5bc05fe50bf1"
/>
<img width="918" height="580" alt="Screenshot 2026-06-10 at 10 46 20"
src="https://github.com/user-attachments/assets/cb83a105-81a1-4090-8d35-9def2bc1b552"
/>


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 adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #54725

Release Notes:

- Fixed rendering of control-characters in syntax tree view
```

## Parents

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

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