Render basic diagnostic messages in project diagnostics view
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
ad05c0cc7a
commit
e1a2897d53
4 changed files with 145 additions and 98 deletions
|
@ -3,7 +3,9 @@ mod fold_map;
|
|||
mod tab_map;
|
||||
mod wrap_map;
|
||||
|
||||
use crate::{Anchor, MultiBuffer, MultiBufferSnapshot, ToOffset, ToPoint};
|
||||
use crate::{
|
||||
multi_buffer::RenderHeaderFn, Anchor, MultiBuffer, MultiBufferSnapshot, ToOffset, ToPoint,
|
||||
};
|
||||
use block_map::{BlockMap, BlockPoint};
|
||||
use fold_map::{FoldMap, ToFoldPoint as _};
|
||||
use gpui::{fonts::FontId, ElementBox, Entity, ModelContext, ModelHandle};
|
||||
|
@ -327,6 +329,21 @@ impl DisplaySnapshot {
|
|||
self.blocks_snapshot.blocks_in_range(rows)
|
||||
}
|
||||
|
||||
pub fn excerpt_headers_in_range<'a>(
|
||||
&'a self,
|
||||
rows: Range<u32>,
|
||||
) -> impl 'a + Iterator<Item = (Range<u32>, RenderHeaderFn)> {
|
||||
let start_row = DisplayPoint::new(rows.start, 0).to_point(self).row;
|
||||
let end_row = DisplayPoint::new(rows.end, 0).to_point(self).row;
|
||||
self.buffer_snapshot
|
||||
.excerpt_headers_in_range(start_row..end_row)
|
||||
.map(move |(rows, render)| {
|
||||
let start_row = Point::new(rows.start, 0).to_display_point(self).row();
|
||||
let end_row = Point::new(rows.end, 0).to_display_point(self).row();
|
||||
(start_row..end_row, render)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn intersects_fold<T: ToOffset>(&self, offset: T) -> bool {
|
||||
self.folds_snapshot.intersects_fold(offset)
|
||||
}
|
||||
|
|
|
@ -590,11 +590,6 @@ impl Editor {
|
|||
scroll_position.y() - self.scroll_top_anchor.to_display_point(&map).row() as f32,
|
||||
);
|
||||
|
||||
debug_assert_eq!(
|
||||
compute_scroll_position(&map, self.scroll_position, &self.scroll_top_anchor),
|
||||
scroll_position
|
||||
);
|
||||
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
|
|
|
@ -631,34 +631,55 @@ impl EditorElement {
|
|||
line_layouts: &[text_layout::Line],
|
||||
cx: &mut LayoutContext,
|
||||
) -> Vec<(u32, ElementBox)> {
|
||||
snapshot
|
||||
.blocks_in_range(rows.clone())
|
||||
.map(|(start_row, block)| {
|
||||
let anchor_row = block
|
||||
.position()
|
||||
.to_point(&snapshot.buffer_snapshot)
|
||||
.to_display_point(snapshot)
|
||||
.row();
|
||||
let mut blocks = Vec::new();
|
||||
|
||||
let anchor_x = if rows.contains(&anchor_row) {
|
||||
line_layouts[(anchor_row - rows.start) as usize]
|
||||
.x_for_index(block.column() as usize)
|
||||
} else {
|
||||
layout_line(anchor_row, snapshot, style, cx.text_layout_cache)
|
||||
.x_for_index(block.column() as usize)
|
||||
};
|
||||
blocks.extend(
|
||||
snapshot
|
||||
.blocks_in_range(rows.clone())
|
||||
.map(|(start_row, block)| {
|
||||
let anchor_row = block
|
||||
.position()
|
||||
.to_point(&snapshot.buffer_snapshot)
|
||||
.to_display_point(snapshot)
|
||||
.row();
|
||||
|
||||
let mut element = block.render(&BlockContext { cx, anchor_x });
|
||||
element.layout(
|
||||
SizeConstraint {
|
||||
min: Vector2F::zero(),
|
||||
max: vec2f(text_width, block.height() as f32 * line_height),
|
||||
},
|
||||
cx,
|
||||
);
|
||||
(start_row, element)
|
||||
})
|
||||
.collect()
|
||||
let anchor_x = if rows.contains(&anchor_row) {
|
||||
line_layouts[(anchor_row - rows.start) as usize]
|
||||
.x_for_index(block.column() as usize)
|
||||
} else {
|
||||
layout_line(anchor_row, snapshot, style, cx.text_layout_cache)
|
||||
.x_for_index(block.column() as usize)
|
||||
};
|
||||
|
||||
let mut element = block.render(&BlockContext { cx, anchor_x });
|
||||
element.layout(
|
||||
SizeConstraint {
|
||||
min: Vector2F::zero(),
|
||||
max: vec2f(text_width, block.height() as f32 * line_height),
|
||||
},
|
||||
cx,
|
||||
);
|
||||
(start_row, element)
|
||||
}),
|
||||
);
|
||||
|
||||
blocks.extend(
|
||||
snapshot
|
||||
.excerpt_headers_in_range(rows.clone())
|
||||
.map(|(rows, render)| {
|
||||
let mut element = render(cx);
|
||||
element.layout(
|
||||
SizeConstraint {
|
||||
min: Vector2F::zero(),
|
||||
max: vec2f(text_width, rows.len() as f32 * line_height),
|
||||
},
|
||||
cx,
|
||||
);
|
||||
(rows.start, element)
|
||||
}),
|
||||
);
|
||||
|
||||
blocks
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue