diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 4ff3a67f46..ad45897009 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -113,8 +113,9 @@ impl ProjectDiagnosticsEditor { let mut header = primary.clone(); header.message = primary.message.split('\n').next().unwrap().to_string(); - excerpt.header_height = 1; + excerpt.header_height = 2; excerpt.render_header = Some(diagnostic_header_renderer( + buffer.clone(), header, self.build_settings.clone(), )); @@ -321,15 +322,16 @@ mod tests { assert_eq!( view.excerpts.read(cx).read(cx).text(), concat!( - "\n", + "\n", // primary diagnostic message + "\n", // filename " let x = vec![];\n", " let y = vec![];\n", " a(x);\n", - "\n", + "\n", // context ellipsis " a(x);\n", " b(y);\n", " // comment 1\n", - "\n", + "\n", // context ellipsis " // comment 3\n", " // comment 4\n", " d(y);" diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 337e4285ae..072f4db1da 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -14,7 +14,7 @@ use display_map::*; pub use element::*; use gpui::{ action, - elements::Text, + elements::*, fonts::TextStyle, geometry::vector::{vec2f, Vector2F}, keymap::Binding, @@ -3783,6 +3783,7 @@ pub fn diagnostic_block_renderer( } pub fn diagnostic_header_renderer( + buffer: ModelHandle, diagnostic: Diagnostic, build_settings: BuildSettings, ) -> RenderHeaderFn { @@ -3790,7 +3791,16 @@ pub fn diagnostic_header_renderer( let settings = build_settings(cx); let mut text_style = settings.style.text.clone(); text_style.color = diagnostic_style(diagnostic.severity, true, &settings.style).text; - Text::new(diagnostic.message.clone(), text_style).boxed() + let file_path = if let Some(file) = buffer.read(cx).file() { + file.path().to_string_lossy().to_string() + } else { + "untitled".to_string() + }; + + Flex::column() + .with_child(Label::new(diagnostic.message.clone(), text_style).boxed()) + .with_child(Label::new(file_path, settings.style.text.clone()).boxed()) + .boxed() }) } @@ -3798,7 +3808,7 @@ pub fn context_header_renderer(build_settings: BuildSettings) -> RenderHeaderFn Arc::new(move |cx| { let settings = build_settings(cx); let text_style = settings.style.text.clone(); - Text::new("...".to_string(), text_style).boxed() + Label::new("...".to_string(), text_style).boxed() }) }