Deduplicate path names in the project diagnostics view
This commit is contained in:
@@ -69,6 +69,7 @@ where
|
||||
pub struct BlockContext<'a> {
|
||||
pub cx: &'a AppContext,
|
||||
pub anchor_x: f32,
|
||||
pub line_number_x: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
@@ -939,7 +940,7 @@ mod tests {
|
||||
start_row..start_row + block.height(),
|
||||
block.column(),
|
||||
block
|
||||
.render(&BlockContext { cx, anchor_x: 0. })
|
||||
.render(&BlockContext { cx, anchor_x: 0., line_number_x: 0., })
|
||||
.name()
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -624,6 +624,7 @@ impl EditorElement {
|
||||
rows: Range<u32>,
|
||||
snapshot: &EditorSnapshot,
|
||||
width: f32,
|
||||
line_number_x: f32,
|
||||
text_x: f32,
|
||||
line_height: f32,
|
||||
style: &EditorStyle,
|
||||
@@ -647,7 +648,7 @@ impl EditorElement {
|
||||
.x_for_index(block.column() as usize)
|
||||
};
|
||||
|
||||
let mut element = block.render(&BlockContext { cx, anchor_x });
|
||||
let mut element = block.render(&BlockContext { cx, anchor_x, line_number_x, });
|
||||
element.layout(
|
||||
SizeConstraint {
|
||||
min: Vector2F::zero(),
|
||||
@@ -812,6 +813,7 @@ impl Element for EditorElement {
|
||||
start_row..end_row,
|
||||
&snapshot,
|
||||
size.x(),
|
||||
gutter_padding,
|
||||
gutter_width + text_offset.x(),
|
||||
line_height,
|
||||
&style,
|
||||
|
||||
Reference in New Issue
Block a user