Give a full-width background to the diagnostic headers

Max Brunsfeld created

Change summary

crates/diagnostics/src/diagnostics.rs |  2 +-
crates/editor/src/editor.rs           |  8 +++++++-
crates/theme/src/theme.rs             |  2 ++
crates/zed/assets/themes/_base.toml   | 22 +++++++++++++++++-----
4 files changed, 27 insertions(+), 7 deletions(-)

Detailed changes

crates/diagnostics/src/diagnostics.rs 🔗

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

crates/editor/src/editor.rs 🔗

@@ -3855,7 +3855,8 @@ pub fn diagnostic_header_renderer(
     Arc::new(move |cx| {
         let settings = build_settings(cx);
         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() {
             file.path().to_string_lossy().to_string()
         } else {
@@ -3869,6 +3870,11 @@ pub fn diagnostic_header_renderer(
                     .boxed(),
             )
             .with_child(Label::new(file_path, settings.style.text.clone()).boxed())
+            .aligned()
+            .left()
+            .contained()
+            .with_style(diagnostic_style.header)
+            .expanded()
             .boxed()
     })
 }

crates/theme/src/theme.rs 🔗

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

crates/zed/assets/themes/_base.toml 🔗

@@ -185,7 +185,7 @@ corner_radius = 6
 
 [project_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]
 text = "$text.1"
@@ -249,15 +249,27 @@ line_number_active = "$text.0.color"
 selection = "$selection.host"
 guest_selections = "$selection.guests"
 error_color = "$status.bad"
-error_diagnostic = { text = "$status.bad" }
 invalid_error_diagnostic = { text = "$text.3.color" }
-warning_diagnostic = { text = "$status.warn" }
 invalid_warning_diagnostic = { text = "$text.3.color" }
-information_diagnostic = { text = "$status.info" }
 invalid_information_diagnostic = { text = "$text.3.color" }
-hint_diagnostic = { text = "$status.info" }
 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]
 background = "$surface.1"
 empty_message = "$text.0"