Add fallback if selected color theme is not present

The fallback is the first available theme when sorted,
this is to make things predictable and to get the same
theme if you open the terminal multiple times
This commit is contained in:
Mattias Eriksson 2024-04-12 13:26:08 +02:00 committed by Jeremy Soller
parent 2903b10247
commit c63e19eea3

View file

@ -1135,7 +1135,15 @@ impl App {
self.pane_model.focus = pane;
match &self.term_event_tx_opt {
Some(term_event_tx) => {
match self.themes.get(&self.config.syntax_theme(profile_id_opt)) {
let colors = self
.themes
.get(&self.config.syntax_theme(profile_id_opt))
.or_else(|| {
let mut keys: Vec<_> = self.themes.keys().collect();
keys.sort_by(|a, b| (&a.0).cmp(&b.0));
keys.first().and_then(|key| self.themes.get(key))
});
match colors {
Some(colors) => {
let current_pane = self.pane_model.focus;
if let Some(tab_model) = self.pane_model.active_mut() {