From c4d700446eaa1626ec68870933a1486556b691a1 Mon Sep 17 00:00:00 2001 From: Wuji Chen Date: Thu, 2 Apr 2026 21:24:15 +0800 Subject: [PATCH] languages: Fix C/C++ preprocessor directive highlight regression (#49031) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - PR #48109 changed the capture name for C/C++ preprocessor directives from `@keyword.directive` to `@preproc`. While semantically correct, the builtin themes had `preproc` defined with colors nearly indistinguishable from plain text (e.g. One Dark `#dce0e5ff`, Ayu Dark `#bfbdb6ff`), making `#include`, `#define`, etc. appear unhighlighted. - This PR updates the `preproc` color in all builtin themes (and the fallback theme) to match their respective `keyword` color, restoring visible highlighting for preprocessor directives. Fixes #49024 ## Side effects - Go uses `@preproc` for `//go:` and `// +build` compiler directives. These will also change from the previous muted gray to the keyword color. This is arguably an improvement — compiler directives are special constructs that benefit from visible highlighting, consistent with how other editors (CLion, VS Code) handle them. ## Test plan - [x] `cargo test -p language highlight_map` passes - [x] Open a C/C++ file and verify `#include`, `#define`, `#ifdef`, etc. are highlighted with the keyword color - [x] Verify across multiple builtin themes (One Dark, Ayu Dark, Gruvbox Dark, etc.) - [x] Open a Go file and verify `//go:` directives are highlighted reasonably 🤖 Generated with [Claude Code](https://claude.com/claude-code) Release Notes: - Fixed C/C++ preprocessor directives (`#include`, `#define`, etc.) appearing unhighlighted in builtin themes. --------- Co-authored-by: Claude Co-authored-by: MrSubidubi --- assets/themes/ayu/ayu.json | 6 +++--- assets/themes/gruvbox/gruvbox.json | 12 ++++++------ assets/themes/one/one.json | 4 ++-- crates/grammars/src/c/highlights.scm | 2 +- crates/grammars/src/cpp/highlights.scm | 2 +- crates/theme/src/fallback_themes.rs | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/assets/themes/ayu/ayu.json b/assets/themes/ayu/ayu.json index c62f9eb11238e21bbc8c04c8fda4bbe7bfc72a81..f27566c4f72cac3938a752c64d95d0500c595306 100644 --- a/assets/themes/ayu/ayu.json +++ b/assets/themes/ayu/ayu.json @@ -283,7 +283,7 @@ "font_weight": null }, "preproc": { - "color": "#bfbdb6ff", + "color": "#ff8f3fff", "font_style": null, "font_weight": null }, @@ -685,7 +685,7 @@ "font_weight": null }, "preproc": { - "color": "#5c6166ff", + "color": "#fa8d3eff", "font_style": null, "font_weight": null }, @@ -1087,7 +1087,7 @@ "font_weight": null }, "preproc": { - "color": "#cccac2ff", + "color": "#ffad65ff", "font_style": null, "font_weight": null }, diff --git a/assets/themes/gruvbox/gruvbox.json b/assets/themes/gruvbox/gruvbox.json index a4fc1b561b36421b353187ef4a2639dae88e901d..4330df54fccae55e7ca077c0da9a891ee71ebe3a 100644 --- a/assets/themes/gruvbox/gruvbox.json +++ b/assets/themes/gruvbox/gruvbox.json @@ -293,7 +293,7 @@ "font_weight": null }, "preproc": { - "color": "#fbf1c7ff", + "color": "#fb4833ff", "font_style": null, "font_weight": null }, @@ -710,7 +710,7 @@ "font_weight": null }, "preproc": { - "color": "#fbf1c7ff", + "color": "#fb4833ff", "font_style": null, "font_weight": null }, @@ -1127,7 +1127,7 @@ "font_weight": null }, "preproc": { - "color": "#fbf1c7ff", + "color": "#fb4833ff", "font_style": null, "font_weight": null }, @@ -1544,7 +1544,7 @@ "font_weight": null }, "preproc": { - "color": "#282828ff", + "color": "#9d0006ff", "font_style": null, "font_weight": null }, @@ -1961,7 +1961,7 @@ "font_weight": null }, "preproc": { - "color": "#282828ff", + "color": "#9d0006ff", "font_style": null, "font_weight": null }, @@ -2378,7 +2378,7 @@ "font_weight": null }, "preproc": { - "color": "#282828ff", + "color": "#9d0006ff", "font_style": null, "font_weight": null }, diff --git a/assets/themes/one/one.json b/assets/themes/one/one.json index 409a5c705c518e83f08dcbaafc1b29c8120beae9..e60b6314b9595ac02bd6a43be4580ba9331ae769 100644 --- a/assets/themes/one/one.json +++ b/assets/themes/one/one.json @@ -290,7 +290,7 @@ "font_weight": null }, "preproc": { - "color": "#dce0e5ff", + "color": "#b477cfff", "font_style": null, "font_weight": null }, @@ -702,7 +702,7 @@ "font_weight": null }, "preproc": { - "color": "#242529ff", + "color": "#a449abff", "font_style": null, "font_weight": null }, diff --git a/crates/grammars/src/c/highlights.scm b/crates/grammars/src/c/highlights.scm index dc5a3bd99937eb3cd1a3af6efb7124aebc4008f1..b73c8e80b8acb61cc0cf47ed6585202eb73f4a7b 100644 --- a/crates/grammars/src/c/highlights.scm +++ b/crates/grammars/src/c/highlights.scm @@ -38,7 +38,7 @@ "#ifndef" "#include" (preproc_directive) -] @preproc +] @keyword.preproc @preproc [ "=" diff --git a/crates/grammars/src/cpp/highlights.scm b/crates/grammars/src/cpp/highlights.scm index e074707d05dec638a1be9ea840c31f47537c438a..281da4215c8269172816c6f37a5e6e866c04a140 100644 --- a/crates/grammars/src/cpp/highlights.scm +++ b/crates/grammars/src/cpp/highlights.scm @@ -196,7 +196,7 @@ type: (primitive_type) @type.builtin "#ifndef" "#include" (preproc_directive) -] @preproc +] @keyword.preproc @preproc (comment) @comment diff --git a/crates/theme/src/fallback_themes.rs b/crates/theme/src/fallback_themes.rs index a3831cafff68a3858a76b8e29071c88579090bcc..a739df3213d297ce8230cfb62a08c91928bd62df 100644 --- a/crates/theme/src/fallback_themes.rs +++ b/crates/theme/src/fallback_themes.rs @@ -357,7 +357,7 @@ pub(crate) fn zed_default_dark() -> Theme { ("number".into(), orange.into()), ("operator".into(), HighlightStyle::default()), ("predictive".into(), HighlightStyle::default()), - ("preproc".into(), HighlightStyle::default()), + ("preproc".into(), purple.into()), ("primary".into(), HighlightStyle::default()), ("property".into(), red.into()), ("punctuation".into(), HighlightStyle::default()),