From 1c6a960bbfc5265ee300f7de30a67d9c1eea3cc8 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Thu, 9 Nov 2023 14:53:04 -0500 Subject: [PATCH] Deal with special case where a VSCode theme doesn't have a `foreground` color Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com> --- crates/theme2/src/themes/solarized.rs | 2 ++ crates/theme_importer/src/vscode/converter.rs | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/theme2/src/themes/solarized.rs b/crates/theme2/src/themes/solarized.rs index ad986fde5c..46ef78213b 100644 --- a/crates/theme2/src/themes/solarized.rs +++ b/crates/theme2/src/themes/solarized.rs @@ -31,6 +31,7 @@ pub fn solarized() -> UserThemeFamily { element_selected: Some(rgba(0x005a6fff).into()), drop_target_background: Some(rgba(0x00435388).into()), ghost_element_hover: Some(rgba(0x004353aa).into()), + text: Some(rgba(0xbbbbbbff).into()), tab_inactive_background: Some(rgba(0x003f51ff).into()), tab_active_background: Some(rgba(0x002a36ff).into()), editor_background: Some(rgba(0x002a35ff).into()), @@ -153,6 +154,7 @@ pub fn solarized() -> UserThemeFamily { element_hover: Some(rgba(0xdec98744).into()), element_selected: Some(rgba(0xdec987ff).into()), ghost_element_hover: Some(rgba(0xdec98744).into()), + text: Some(rgba(0x333333ff).into()), tab_inactive_background: Some(rgba(0xd3cbb7ff).into()), tab_active_background: Some(rgba(0xfdf6e3ff).into()), editor_background: Some(rgba(0xfdf6e3ff).into()), diff --git a/crates/theme_importer/src/vscode/converter.rs b/crates/theme_importer/src/vscode/converter.rs index 39cc003094..916b2f27a6 100644 --- a/crates/theme_importer/src/vscode/converter.rs +++ b/crates/theme_importer/src/vscode/converter.rs @@ -157,7 +157,17 @@ impl VsCodeThemeConverter { text: vscode_colors .foreground .as_ref() - .traverse(|color| try_parse_color(&color))?, + .traverse(|color| try_parse_color(&color))? + .or_else(|| { + self.theme + .token_colors + .iter() + .find(|token_color| token_color.scope.is_none()) + .and_then(|token_color| token_color.settings.foreground.as_ref()) + .traverse(|color| try_parse_color(&color)) + .ok() + .flatten() + }), tab_active_background: vscode_colors .tab_active_background .as_ref()