From 4eb25871773b53f3bd6f899ca1dc08c100f1b017 Mon Sep 17 00:00:00 2001 From: Matt Paras Date: Wed, 13 Nov 2024 08:58:20 -0800 Subject: [PATCH] make sure arbitrary keys can be added to themes after construction --- helix-view/src/theme.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index e25e5cfc8..1769d662f 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -317,12 +317,15 @@ impl Theme { } pub fn set(&mut self, scope: String, style: Style) { - self.styles.insert(scope.to_string(), style); - - for (name, highlights) in self.scopes.iter().zip(self.highlights.iter_mut()) { - if *name == scope { - *highlights = style; + if self.styles.insert(scope.to_string(), style).is_some() { + for (name, highlights) in self.scopes.iter().zip(self.highlights.iter_mut()) { + if *name == scope { + *highlights = style; + } } + } else { + self.scopes.push(scope); + self.highlights.push(style); } }