Fade out unnecessary code

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra
2022-03-15 15:51:59 +01:00
co-authored by Nathan Sobo
parent 41bd58e3ac
commit 7155dabf5b
10 changed files with 73 additions and 34 deletions
+2 -1
View File
@@ -819,7 +819,8 @@ impl<'a> Iterator for BlockChunks<'a> {
text: unsafe { std::str::from_utf8_unchecked(&NEWLINES[..line_count as usize]) },
syntax_highlight_id: None,
highlight_style: None,
diagnostic: None,
diagnostic_severity: None,
is_unnecessary: false,
});
}
+2 -1
View File
@@ -1078,7 +1078,8 @@ impl<'a> Iterator for FoldChunks<'a> {
text: output_text,
syntax_highlight_id: None,
highlight_style: None,
diagnostic: None,
diagnostic_severity: None,
is_unnecessary: false,
});
}
+18 -15
View File
@@ -665,22 +665,25 @@ impl EditorElement {
}
}
if let Some(severity) = chunk.diagnostic {
let diagnostic_style = super::diagnostic_style(severity, true, style);
let diagnostic_highlight = HighlightStyle {
underline: Some(Underline {
color: Some(diagnostic_style.message.text.color),
thickness: 1.0.into(),
squiggly: true,
}),
..Default::default()
};
let mut diagnostic_highlight = HighlightStyle {
..Default::default()
};
if let Some(highlight_style) = highlight_style.as_mut() {
highlight_style.highlight(diagnostic_highlight);
} else {
highlight_style = Some(diagnostic_highlight);
}
if chunk.is_unnecessary {
diagnostic_highlight.fade_out = Some(style.unnecessary_code_fade);
} else if let Some(severity) = chunk.diagnostic_severity {
let diagnostic_style = super::diagnostic_style(severity, true, style);
diagnostic_highlight.underline = Some(Underline {
color: Some(diagnostic_style.message.text.color),
thickness: 1.0.into(),
squiggly: true,
});
}
if let Some(highlight_style) = highlight_style.as_mut() {
highlight_style.highlight(diagnostic_highlight);
} else {
highlight_style = Some(diagnostic_highlight);
}
(chunk.text, highlight_style)