make sure arbitrary keys can be added to themes after construction

pull/8675/merge^2
Matt Paras 2024-11-13 08:58:20 -08:00
parent 7cbde094c4
commit 4eb2587177
1 changed files with 8 additions and 5 deletions

View File

@ -317,12 +317,15 @@ impl Theme {
} }
pub fn set(&mut self, scope: String, style: Style) { pub fn set(&mut self, scope: String, style: Style) {
self.styles.insert(scope.to_string(), style); if self.styles.insert(scope.to_string(), style).is_some() {
for (name, highlights) in self.scopes.iter().zip(self.highlights.iter_mut()) {
for (name, highlights) in self.scopes.iter().zip(self.highlights.iter_mut()) { if *name == scope {
if *name == scope { *highlights = style;
*highlights = style; }
} }
} else {
self.scopes.push(scope);
self.highlights.push(style);
} }
} }