From 94e9c7fd5b25599876bd665985b173a8b4c26544 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 6 Jan 2022 17:55:56 -0800 Subject: [PATCH] Give a full-width background to the diagnostic headers --- 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(-) diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index dfaac9f150..f6cc659818 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/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, diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 4d3aa058be..b9c57de130 100644 --- a/crates/editor/src/editor.rs +++ b/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() }) } diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 6a67789afe..e91f0addb7 100644 --- a/crates/theme/src/theme.rs +++ b/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)] diff --git a/crates/zed/assets/themes/_base.toml b/crates/zed/assets/themes/_base.toml index 4063fc92f9..2fa2bde545 100644 --- a/crates/zed/assets/themes/_base.toml +++ b/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"