Update diagnostics style

This commit is contained in:
Nate Butler 2023-12-01 14:52:17 -05:00
parent 0d33f01fa4
commit f5679f98d6

View file

@ -774,24 +774,39 @@ fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {
Arc::new(move |_| { Arc::new(move |_| {
h_stack() h_stack()
.id("diagnostic header") .id("diagnostic header")
.gap_3() .py_2()
.bg(gpui::red()) .pl_10()
.map(|stack| { .pr_5()
let icon = if diagnostic.severity == DiagnosticSeverity::ERROR { .w_full()
IconElement::new(Icon::XCircle).color(Color::Error) .justify_between()
} else { .gap_2()
IconElement::new(Icon::ExclamationTriangle).color(Color::Warning) .child(
}; h_stack()
.gap_3()
stack.child(div().pl_8().child(icon)) .map(|stack| {
}) let icon = if diagnostic.severity == DiagnosticSeverity::ERROR {
.when_some(diagnostic.source.as_ref(), |stack, source| { IconElement::new(Icon::XCircle).color(Color::Error)
stack.child(Label::new(format!("{source}:")).color(Color::Accent)) } else {
}) IconElement::new(Icon::ExclamationTriangle).color(Color::Warning)
.child(HighlightedLabel::new(message.clone(), highlights.clone())) };
.when_some(diagnostic.code.as_ref(), |stack, code| { stack.child(icon)
stack.child(Label::new(code.clone())) })
}) .child(
h_stack()
.gap_1()
.child(HighlightedLabel::new(message.clone(), highlights.clone()))
.when_some(diagnostic.code.as_ref(), |stack, code| {
stack.child(Label::new(format!("({code})")).color(Color::Muted))
}),
),
)
.child(
h_stack()
.gap_1()
.when_some(diagnostic.source.as_ref(), |stack, source| {
stack.child(Label::new(format!("{source}")).color(Color::Muted))
}),
)
.into_any_element() .into_any_element()
}) })
} }
@ -802,11 +817,22 @@ pub(crate) fn render_summary(summary: &DiagnosticSummary) -> AnyElement {
label.into_any_element() label.into_any_element()
} else { } else {
h_stack() h_stack()
.bg(gpui::red()) .gap_1()
.child(IconElement::new(Icon::XCircle)) .when(summary.error_count > 0, |then| {
.child(Label::new(summary.error_count.to_string())) then.child(
.child(IconElement::new(Icon::ExclamationTriangle)) h_stack()
.child(Label::new(summary.warning_count.to_string())) .gap_1()
.child(IconElement::new(Icon::XCircle).color(Color::Error))
.child(Label::new(summary.error_count.to_string())),
)
})
.when(summary.warning_count > 0, |then| {
then.child(
h_stack()
.child(IconElement::new(Icon::ExclamationTriangle).color(Color::Warning))
.child(Label::new(summary.warning_count.to_string())),
)
})
.into_any_element() .into_any_element()
} }
} }