From d1e0891260b1eda642221f96a2e230185fd748d3 Mon Sep 17 00:00:00 2001
From: iximeow <git@iximeow.net>
Date: Wed, 12 Mar 2025 13:52:07 -0700
Subject: [PATCH] warn when configured theme is unusable for color reasons
 (#13058)

if `config.toml` either does not have `editor.true-color` or sets
it to false, many (most?) themes stop being usable. when loading such a
theme, Helix falls back to the default theme, but didn't mention this
anywhere - even in `~/.cache/helix/helix.log` when run with `-v`.

if this occurs when reloading a theme at runtime with `:theme`, there's
a fairly helpful error about

> `theme requires true color support`

seems worth logging about this if it happens during startup too.
---
 helix-term/src/application.rs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 7f491309..cb270b86 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -441,7 +441,17 @@ impl Application {
                         e
                     })
                     .ok()
-                    .filter(|theme| (true_color || theme.is_16_color()))
+                    .filter(|theme| {
+                        let colors_ok = true_color || theme.is_16_color();
+                        if !colors_ok {
+                            log::warn!(
+                                "loaded theme `{}` but cannot use it because true color \
+                                support is not enabled",
+                                theme.name()
+                            );
+                        }
+                        colors_ok
+                    })
             })
             .unwrap_or_else(|| editor.theme_loader.default_theme(true_color));
         editor.set_theme(theme);