theme: Properly merge SyntaxTheme styles to allow for partial overrides (#11911)

This PR improves the merging behavior for the `SyntaxTheme` such that
user-provided values get merged into the base theme.

This makes it possible to override individual styles without clobbering
the unspecified styles in the base theme.

Release Notes:

- Improved merging of `syntax` styles in the theme.
This commit is contained in:
Marshall Bowers
2024-05-16 09:58:47 -04:00
committed by GitHub
parent 4ba57d730b
commit 178ffabca6
3 changed files with 188 additions and 44 deletions
+2 -9
View File
@@ -325,15 +325,8 @@ impl ThemeSettings {
.status
.refine(&theme_overrides.status_colors_refinement());
base_theme.styles.player.merge(&theme_overrides.players);
base_theme.styles.syntax = Arc::new(SyntaxTheme {
highlights: {
let mut highlights = base_theme.styles.syntax.highlights.clone();
// Overrides come second in the highlight list so that they take precedence
// over the ones in the base theme.
highlights.extend(theme_overrides.syntax_overrides());
highlights
},
});
base_theme.styles.syntax =
SyntaxTheme::merge(base_theme.styles.syntax, theme_overrides.syntax_overrides());
self.active_theme = Arc::new(base_theme);
}