From c63e19eea37b2e39626da1b7618d79e1b17922af Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Fri, 12 Apr 2024 13:26:08 +0200 Subject: [PATCH] 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 --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e5597da..15e1ded 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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() {