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

View file

@ -1174,7 +1174,7 @@ mod tests {
for chunk in snapshot.chunks(rows, true) {
let color = chunk
.syntax_highlight_id
.and_then(|id| id.style(theme).map(|s| s.color));
.and_then(|id| id.style(theme)?.color);
if let Some((last_chunk, last_color)) = chunks.last_mut() {
if color == *last_color {
last_chunk.push_str(chunk.text);