Restore underline for warnings about unused code

This commit is contained in:
Max Brunsfeld 2022-03-15 13:13:33 -07:00
parent a0224cbe71
commit 76fc9c955e
2 changed files with 15 additions and 12 deletions

View file

@ -4211,7 +4211,7 @@ impl Editor {
};
let group = diagnostics.find_map(|entry| {
if entry.diagnostic.is_primary
&& !entry.diagnostic.is_unnecessary
&& entry.diagnostic.severity <= DiagnosticSeverity::WARNING
&& !entry.range.is_empty()
&& Some(entry.range.end) != active_primary_range.as_ref().map(|r| *r.end())
{

View file

@ -21,7 +21,7 @@ use gpui::{
MutableAppContext, PaintContext, Quad, Scene, SizeConstraint, ViewContext, WeakViewHandle,
};
use json::json;
use language::Bias;
use language::{Bias, DiagnosticSeverity};
use smallvec::SmallVec;
use std::{
cmp::{self, Ordering},
@ -665,19 +665,22 @@ impl EditorElement {
}
}
let mut diagnostic_highlight = HighlightStyle {
..Default::default()
};
let mut diagnostic_highlight = HighlightStyle::default();
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(severity) = chunk.diagnostic_severity {
// Omit underlines for HINT/INFO diagnostics on 'unnecessary' code.
if severity <= DiagnosticSeverity::WARNING || !chunk.is_unnecessary {
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() {