Make all HighlightStyle properties optional

Previously, some of those properties such the font weight, style and color
would be mandatory: when the theme didn't specify them, Zed would use a default
value during deserialization. This meant that those default properties would
unconditionally override the base text style, causing a rendering bug when
combining syntax highlights with diagnostic styles.

This commit fixes that by making `HighlightStyle`s more additive: each property
can be set independently and only the properties that theme specifies get
overridden in the base text style.
This commit is contained in:
Antonio Scandurra
2022-03-15 10:39:43 +01:00
parent 72692f1700
commit fbf7cdf4f2
10 changed files with 149 additions and 146 deletions
+6 -6
View File
@@ -425,21 +425,21 @@ mod tests {
let menlo_regular = RunStyle {
font_id: fonts.select_font(&menlo, &Properties::new()).unwrap(),
color: Default::default(),
underline: None,
underline: Default::default(),
};
let menlo_italic = RunStyle {
font_id: fonts
.select_font(&menlo, &Properties::new().style(Style::Italic))
.unwrap(),
color: Default::default(),
underline: None,
underline: Default::default(),
};
let menlo_bold = RunStyle {
font_id: fonts
.select_font(&menlo, &Properties::new().weight(Weight::BOLD))
.unwrap(),
color: Default::default(),
underline: None,
underline: Default::default(),
};
assert_ne!(menlo_regular, menlo_italic);
assert_ne!(menlo_regular, menlo_bold);
@@ -466,13 +466,13 @@ mod tests {
let zapfino_regular = RunStyle {
font_id: fonts.select_font(&zapfino, &Properties::new())?,
color: Default::default(),
underline: None,
underline: Default::default(),
};
let menlo = fonts.load_family("Menlo")?;
let menlo_regular = RunStyle {
font_id: fonts.select_font(&menlo, &Properties::new())?,
color: Default::default(),
underline: None,
underline: Default::default(),
};
let text = "This is, m𐍈re 𐍈r less, Zapfino!𐍈";
@@ -551,7 +551,7 @@ mod tests {
let style = RunStyle {
font_id: fonts.select_font(&font_ids, &Default::default()).unwrap(),
color: Default::default(),
underline: None,
underline: Default::default(),
};
let line = "\u{feff}";