Deduplicate path names in the project diagnostics view

This commit is contained in:
Max Brunsfeld 2022-01-11 14:56:54 -08:00
parent a9937ee8be
commit b5ee095da9
5 changed files with 120 additions and 88 deletions

View file

@ -3851,47 +3851,6 @@ pub fn diagnostic_block_renderer(
})
}
pub fn diagnostic_header_renderer(
buffer: ModelHandle<Buffer>,
diagnostic: Diagnostic,
is_valid: bool,
build_settings: BuildSettings,
) -> RenderBlock {
Arc::new(move |cx| {
let settings = build_settings(cx);
let mut text_style = settings.style.text.clone();
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 {
"untitled".to_string()
};
Flex::column()
.with_child(
Text::new(diagnostic.message.clone(), text_style)
.with_soft_wrap(false)
.boxed(),
)
.with_child(Label::new(file_path, settings.style.text.clone()).boxed())
.aligned()
.left()
.contained()
.with_style(diagnostic_style.header)
.expanded()
.boxed()
})
}
pub fn context_header_renderer(build_settings: BuildSettings) -> RenderBlock {
Arc::new(move |cx| {
let settings = build_settings(cx);
let text_style = settings.style.text.clone();
Label::new("...".to_string(), text_style).boxed()
})
}
pub fn diagnostic_style(
severity: DiagnosticSeverity,
valid: bool,