Skip to content

Fix keyword color too similar to function color in 2026 themes - #331643

Open
srikanthananthula (srikanthananthula63053) wants to merge 2 commits into
microsoft:mainfrom
srikanthananthula63053:fix-331622-2026-dark-theme-keyword-color
Open

Fix keyword color too similar to function color in 2026 themes#331643
srikanthananthula (srikanthananthula63053) wants to merge 2 commits into
microsoft:mainfrom
srikanthananthula63053:fix-331622-2026-dark-theme-keyword-color

Conversation

@srikanthananthula63053

@srikanthananthula63053 srikanthananthula (srikanthananthula63053) commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Problem

Fixes #331622.

In the 2026 Dark Theme, keywords (if, import, try, except, for, while, etc.) are visually hard to distinguish from function names, as reported with a screenshot in the issue.

Root cause

2026-dark.json defines its own tokenColors rule for the generic "keyword" scope (#ff7b72, coral-red). However, dark_plus.json (an ancestor via the theme include chain: 2026-dark.jsondark_modern.jsondark_plus.json) already defines a more specific rule for "keyword.control" (#C586C0, magenta).

VS Code's TextMate scope matching always prefers the most specific matching selector, regardless of which theme in the include chain defined it. Since most real keywords use scopes like keyword.control.flow.python or keyword.control.import.python, they match keyword.control (2 segments) rather than the theme's own keyword (1 segment) rule — so the inherited #C586C0 wins over the theme's intended #ff7b72.

#C586C0 (magenta) sits visually very close to the theme's entity.name.function color (#D2A8FF, lavender) — both are pastel purple/magenta tones on the same near-black background, which is exactly the collision reported in the issue.

I confirmed this by downloading the screenshot attached to the issue and sampling its pixels directly: import/from/as render as #C586C0, while the called/imported function name renders as #D2A8FF.

The same issue exists in 2026-light.json (keyword = #cf222e, shadowed by light_plus.json's keyword.control = #AF00DB, close to that theme's entity.name.function = #8250df), so I fixed both for consistency.

Fix

Minimal, one rule changed per theme: add "keyword.control" alongside "keyword" in each theme's own tokenColors, so the theme's intended color wins for control-flow keywords too — the same pattern the theme already uses elsewhere (e.g. its storage.modifier.* overrides).

 {
-    "scope": "keyword",
+    "scope": [
+        "keyword",
+        "keyword.control"
+    ],
     "settings": {
         "foreground": "#ff7b72"
     }
 },

(analogous change in 2026-light.json with #cf222e)

Validation

There are no existing automated tests asserting specific theme color values in this repo, so none were added — theme color changes are conventionally validated visually. To verify without a full Electron build, I wrote a small script that replicates the actual theme include-merge and TextMate scope-specificity resolution logic from colorThemeData.ts, and confirmed:

Scope Before After
keyword.control.flow.python #C586C0 #ff7b72
keyword.control.import.python #C586C0 #ff7b72
entity.name.function #D2A8FF (unchanged) #D2A8FF (unchanged)

I also rendered a before/after swatch confirming the visual improvement, and re-verified the equivalent scopes/colors for the light theme fix.

Test plan

  • Confirmed root cause via pixel-sampling the issue's screenshot
  • Confirmed fix via scope-resolution simulation matching production merge logic
  • git diff reviewed — only the two theme JSON files touched, one rule each

Copilot AI balanced review requested due to automatic review settings August 19, 2026 14:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the 2026 default themes to ensure control-flow keywords receive the same keyword coloring as other keywords.

Changes:

  • Expanded the scope selector for keyword styling from a single "keyword" scope to an array including "keyword.control" in both light and dark themes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
extensions/theme-defaults/themes/2026-light.json Adds keyword.control to the keyword color scope list for the light theme.
extensions/theme-defaults/themes/2026-dark.json Adds keyword.control to the keyword color scope list for the dark theme.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The theme's own "keyword" rule (#ff7b72) was being shadowed by the
more specific "keyword.control" rule inherited from dark_plus.json
(#C586C0) for most real keywords (if/return/import/try/except/for/
while, etc.), since TextMate scope matching picks the most specific
matching selector regardless of which theme defined it.

That inherited magenta ends up visually very close to the theme's
own entity.name.function color (#D2A8FF), which is what issue
microsoft#331622 reports as "keyword color too similar to function color".

Add "keyword.control" alongside "keyword" so the theme's intended
coral-red wins for control-flow keywords, matching how the theme
already resolves similar collisions for storage.modifier scopes.

Fixes microsoft#331622
The same specificity shadowing described in the previous commit
also affects 2026-light.json: the theme's "keyword" rule (#cf222e)
was shadowed by light_plus.json's more specific "keyword.control"
rule (#AF00DB), which sits close to this theme's entity.name.function
color (#8250df). Apply the same fix for consistency, per microsoft#331622.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great catch on this edge case. Fallback logic is robust.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2026 Dark Theme] Keyword color is too similar to function color

5 participants