Skip to content

Conversation

@azeier
Copy link
Contributor

@azeier azeier commented Oct 8, 2025

Related to #9461, inspired by #39683

await and yield both seem somewhat debatable on whether they should be considered the be control flow keywords.

For now I went with:

  • await: no – The control flow effect of await is at a level does not seem relevant for syntax highlighting.
  • yield: yes – yield directly affects the output of a generator, and is also included for consistency with Rust (Highlight control flow in Rust/C/C++ #39683).

Happy to change these either direction.

SCR-20251008-izus

Release Notes:

  • Improved granularity of keyword highlighting for JS/TS/TSX: Themes can now specify keyword.control for control flow keywords like if, else, return, etc.

@cla-bot
Copy link

cla-bot bot commented Oct 8, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @azeier on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@maxdeviant maxdeviant changed the title languages: Separate control flow keywords for js/ts/tsx languages: Separate control flow keywords for JS/TS/TSX Oct 8, 2025
@azeier
Copy link
Contributor Author

azeier commented Oct 8, 2025

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 8, 2025
@cla-bot
Copy link

cla-bot bot commented Oct 8, 2025

The cla-bot has been summoned, and re-checked this pull request!

@azeier azeier force-pushed the js-control-keywords branch from 87dc78d to 2f8a9a2 Compare October 16, 2025 15:14
@azeier
Copy link
Contributor Author

azeier commented Oct 16, 2025

switch_default is now handled explicitly, to avoid highlighting export default.

@MrSubidubi MrSubidubi self-assigned this Oct 20, 2025
Copy link
Member

@MrSubidubi MrSubidubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

Regarding yield/await: I think I am leaning against await and somewhat against yield, because both do not really change the control flow in a "classical" way like e.g. return would.

That said, Helix highlights both: https://github.com/helix-editor/helix/blob/97aee4950fd9a08a78415cd8992354ae5cf3aaf0/runtime/queries/rust/highlights.scm#L233-L234

but then, just because they do does not mean we have to.

Given that I merged the other PR as is, I think it is fine to go with this one as is as well and iterate on it as needed.

Hence, thank you for this PR, your added input, big thank you for the very well crafted release notes and - finally - congratulations to your first contribution! 🎉

@MrSubidubi MrSubidubi merged commit 96415e2 into zed-industries:main Oct 20, 2025
22 checks passed
@azeier azeier deleted the js-control-keywords branch October 20, 2025 20:27
@wesguirra
Copy link

Any theme supporting this as of now?

@azeier
Copy link
Contributor Author

azeier commented Oct 23, 2025

I suspect it will take a while for themes to pick up on changes like this, but you can override it in your settings.json:

  "experimental.theme_overrides": {
    "syntax": {
      "keyword.control": {
        "color": "#ffffff"
      }
    }
  },

@hisbvdis
Copy link

@azeier , hello.
I tried to make PR with some change to the TSX language highlighting, but my PR was rejected.
And I can't build Zed from repository according to the manual.

If you have a free time, maybe you could create another PR with adding ability to highligh JSX-components besides JSX tags?
My previouse PR: #37183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants