diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 7541563971..c411e31ad8 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -12,7 +12,9 @@ use gpui::{ action, elements::*, keymap::Binding, AnyViewHandle, AppContext, Entity, ModelHandle, MutableAppContext, RenderContext, Task, View, ViewContext, ViewHandle, WeakViewHandle, }; -use language::{Bias, Buffer, DiagnosticEntry, Point, Selection, SelectionGoal}; +use language::{ + Bias, Buffer, DiagnosticEntry, DiagnosticSeverity, Point, Selection, SelectionGoal, +}; use postage::watch; use project::{Project, ProjectPath}; use std::{ @@ -353,6 +355,7 @@ impl ProjectDiagnosticsEditor { height: 2, render: diagnostic_header_renderer( message, + primary.severity, self.build_settings.clone(), ), disposition: BlockDisposition::Above, @@ -661,7 +664,7 @@ fn path_header_renderer(buffer: ModelHandle, build_settings: BuildSettin path = file .path() .parent() - .map(|p| p.to_string_lossy().to_string()); + .map(|p| p.to_string_lossy().to_string() + "/"); } Flex::row() @@ -690,7 +693,11 @@ fn path_header_renderer(buffer: ModelHandle, build_settings: BuildSettin }) } -fn diagnostic_header_renderer(message: String, build_settings: BuildSettings) -> RenderBlock { +fn diagnostic_header_renderer( + message: String, + severity: DiagnosticSeverity, + build_settings: BuildSettings, +) -> RenderBlock { enum Run { Text(Range), Code(Range), @@ -722,8 +729,23 @@ fn diagnostic_header_renderer(message: String, build_settings: BuildSettings) -> Arc::new(move |cx| { let settings = build_settings(cx); let style = &settings.style.diagnostic_header; + let icon = if severity == DiagnosticSeverity::ERROR { + Svg::new("icons/diagnostic-error-10.svg") + .with_color(settings.style.error_diagnostic.text) + } else { + Svg::new("icons/diagnostic-warning-10.svg") + .with_color(settings.style.warning_diagnostic.text) + }; Flex::row() + .with_child( + icon.constrained() + .with_height(style.icon.width) + .aligned() + .contained() + .with_style(style.icon.container) + .boxed(), + ) .with_children(runs.iter().map(|run| { let container_style; let text_style; diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index bb24e8ff75..ec0e3cb835 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3853,6 +3853,7 @@ impl EditorSettings { container: Default::default(), text: text.clone(), }, + icon: Default::default(), }, error_diagnostic: Default::default(), invalid_error_diagnostic: Default::default(), diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index ac383d2d52..d9383d80a0 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -277,6 +277,14 @@ pub struct DiagnosticHeader { pub container: ContainerStyle, pub text: TextStyle, pub highlighted_text: ContainedText, + pub icon: DiagnosticHeaderIcon, +} + +#[derive(Clone, Deserialize, Default)] +pub struct DiagnosticHeaderIcon { + #[serde(flatten)] + pub container: ContainerStyle, + pub width: f32, } #[derive(Copy, Clone, Deserialize, Default)] @@ -352,6 +360,7 @@ impl InputEditorStyle { container: Default::default(), text: self.text.clone(), }, + icon: Default::default(), }, error_diagnostic: Default::default(), invalid_error_diagnostic: Default::default(), diff --git a/crates/zed/assets/icons/diagnostic-error-10.svg b/crates/zed/assets/icons/diagnostic-error-10.svg new file mode 100644 index 0000000000..d01bc3a23d --- /dev/null +++ b/crates/zed/assets/icons/diagnostic-error-10.svg @@ -0,0 +1,3 @@ + + + diff --git a/crates/zed/assets/icons/diagnostic-warning-10.svg b/crates/zed/assets/icons/diagnostic-warning-10.svg new file mode 100644 index 0000000000..bfd9ed7c6f --- /dev/null +++ b/crates/zed/assets/icons/diagnostic-warning-10.svg @@ -0,0 +1,3 @@ + + + diff --git a/crates/zed/assets/themes/_base.toml b/crates/zed/assets/themes/_base.toml index 852553c96d..acead59906 100644 --- a/crates/zed/assets/themes/_base.toml +++ b/crates/zed/assets/themes/_base.toml @@ -258,12 +258,13 @@ invalid_hint_diagnostic = { text = "$text.3.color" } [editor.diagnostic_path_header] filename = { extends = "$text.0", size = 14 } -path = { extends = "$text.1", size = 14, margin.left = 4 } +path = { extends = "$text.2", size = 14, margin.left = 12 } [editor.diagnostic_header] background = "$state.active_line" border = { width = 1, top = true, bottom = true, color = "$border.0" } text = { extends = "$text.1", size = 14 } +icon = { width = 10, margin.right = 8 } [editor.diagnostic_header.highlighted_text] extends = "$editor.diagnostic_header.text"