Give a full-width background to the diagnostic headers

This commit is contained in:
Max Brunsfeld 2022-01-06 17:55:56 -08:00
parent 2b36ab0de7
commit 94e9c7fd5b
4 changed files with 27 additions and 7 deletions

View file

@ -289,7 +289,7 @@ impl ProjectDiagnosticsEditor {
diagnostic_blocks.push(DiagnosticBlock::Header(header.clone())); diagnostic_blocks.push(DiagnosticBlock::Header(header.clone()));
blocks_to_add.push(BlockProperties { blocks_to_add.push(BlockProperties {
position: header_position, position: header_position,
height: 2, height: 3,
render: diagnostic_header_renderer( render: diagnostic_header_renderer(
buffer.clone(), buffer.clone(),
header, header,

View file

@ -3855,7 +3855,8 @@ pub fn diagnostic_header_renderer(
Arc::new(move |cx| { Arc::new(move |cx| {
let settings = build_settings(cx); let settings = build_settings(cx);
let mut text_style = settings.style.text.clone(); let mut text_style = settings.style.text.clone();
text_style.color = diagnostic_style(diagnostic.severity, is_valid, &settings.style).text; let diagnostic_style = diagnostic_style(diagnostic.severity, is_valid, &settings.style);
text_style.color = diagnostic_style.text;
let file_path = if let Some(file) = buffer.read(&**cx).file() { let file_path = if let Some(file) = buffer.read(&**cx).file() {
file.path().to_string_lossy().to_string() file.path().to_string_lossy().to_string()
} else { } else {
@ -3869,6 +3870,11 @@ pub fn diagnostic_header_renderer(
.boxed(), .boxed(),
) )
.with_child(Label::new(file_path, settings.style.text.clone()).boxed()) .with_child(Label::new(file_path, settings.style.text.clone()).boxed())
.aligned()
.left()
.contained()
.with_style(diagnostic_style.header)
.expanded()
.boxed() .boxed()
}) })
} }

View file

@ -261,6 +261,8 @@ pub struct EditorStyle {
#[derive(Copy, Clone, Deserialize, Default)] #[derive(Copy, Clone, Deserialize, Default)]
pub struct DiagnosticStyle { pub struct DiagnosticStyle {
pub text: Color, pub text: Color,
#[serde(default)]
pub header: ContainerStyle,
} }
#[derive(Clone, Copy, Default, Deserialize)] #[derive(Clone, Copy, Default, Deserialize)]

View file

@ -185,7 +185,7 @@ corner_radius = 6
[project_panel] [project_panel]
extends = "$panel" extends = "$panel"
padding.top = 6 # ($workspace.tab.height - $project_panel.entry.height) / 2 padding.top = 6 # ($workspace.tab.height - $project_panel.entry.height) / 2
[project_panel.entry] [project_panel.entry]
text = "$text.1" text = "$text.1"
@ -249,15 +249,27 @@ line_number_active = "$text.0.color"
selection = "$selection.host" selection = "$selection.host"
guest_selections = "$selection.guests" guest_selections = "$selection.guests"
error_color = "$status.bad" error_color = "$status.bad"
error_diagnostic = { text = "$status.bad" }
invalid_error_diagnostic = { text = "$text.3.color" } invalid_error_diagnostic = { text = "$text.3.color" }
warning_diagnostic = { text = "$status.warn" }
invalid_warning_diagnostic = { text = "$text.3.color" } invalid_warning_diagnostic = { text = "$text.3.color" }
information_diagnostic = { text = "$status.info" }
invalid_information_diagnostic = { text = "$text.3.color" } invalid_information_diagnostic = { text = "$text.3.color" }
hint_diagnostic = { text = "$status.info" }
invalid_hint_diagnostic = { text = "$text.3.color" } invalid_hint_diagnostic = { text = "$text.3.color" }
[editor.error_diagnostic]
text = "$status.bad"
header = { padding = { left = 10 }, background = "#ffffff08" }
[editor.warning_diagnostic]
text = "$status.warn"
header = { padding = { left = 10 }, background = "#ffffff08" }
[editor.information_diagnostic]
text = "$status.info"
header = { padding = { left = 10 }, background = "#ffffff08" }
[editor.hint_diagnostic]
text = "$status.info"
header = { padding = { left = 10 }, background = "#ffffff08" }
[project_diagnostics] [project_diagnostics]
background = "$surface.1" background = "$surface.1"
empty_message = "$text.0" empty_message = "$text.0"