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,13 +317,16 @@ impl Theme {
}
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()) {
if *name == scope {
*highlights = style;
}
}
} else {
self.scopes.push(scope);
self.highlights.push(style);
}
}
/// Get the style of a scope, falling back to dot separated broader