Ensure path headers appear before first diagnostic header
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
ac0d55222f
commit
6ad9ff10c1
2 changed files with 28 additions and 21 deletions
|
@ -423,28 +423,27 @@ impl ProjectDiagnosticsEditor {
|
||||||
render: path_header_renderer(buffer, self.build_settings.clone()),
|
render: path_header_renderer(buffer, self.build_settings.clone()),
|
||||||
disposition: BlockDisposition::Above,
|
disposition: BlockDisposition::Above,
|
||||||
});
|
});
|
||||||
let mut block_ids = editor
|
let block_ids = editor.insert_blocks(
|
||||||
.insert_blocks(
|
blocks_to_add
|
||||||
header_block
|
.into_iter()
|
||||||
.into_iter()
|
.map(|block| {
|
||||||
.chain(blocks_to_add.into_iter().map(|block| {
|
let (excerpt_id, text_anchor) = block.position;
|
||||||
let (excerpt_id, text_anchor) = block.position;
|
BlockProperties {
|
||||||
BlockProperties {
|
position: excerpts_snapshot.anchor_in_excerpt(excerpt_id, text_anchor),
|
||||||
position: excerpts_snapshot
|
height: block.height,
|
||||||
.anchor_in_excerpt(excerpt_id, text_anchor),
|
render: block.render,
|
||||||
height: block.height,
|
disposition: block.disposition,
|
||||||
render: block.render,
|
}
|
||||||
disposition: block.disposition,
|
})
|
||||||
}
|
.chain(header_block.into_iter()),
|
||||||
})),
|
cx,
|
||||||
cx,
|
);
|
||||||
)
|
|
||||||
.into_iter();
|
|
||||||
|
|
||||||
path_state.header = block_ids.next();
|
let mut block_ids = block_ids.into_iter();
|
||||||
for group_state in &mut groups_to_add {
|
for group_state in &mut groups_to_add {
|
||||||
group_state.blocks = block_ids.by_ref().take(group_state.block_count).collect();
|
group_state.blocks = block_ids.by_ref().take(group_state.block_count).collect();
|
||||||
}
|
}
|
||||||
|
path_state.header = block_ids.next();
|
||||||
});
|
});
|
||||||
|
|
||||||
for ix in group_ixs_to_remove.into_iter().rev() {
|
for ix in group_ixs_to_remove.into_iter().rev() {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use gpui::{AppContext, ElementBox};
|
||||||
use language::Chunk;
|
use language::Chunk;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{self, Ordering},
|
cmp::{self, Ordering, Reverse},
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
ops::{Deref, Range},
|
ops::{Deref, Range},
|
||||||
sync::{
|
sync::{
|
||||||
|
@ -276,7 +276,11 @@ impl BlockMap {
|
||||||
(position.row(), column, block.clone())
|
(position.row(), column, block.clone())
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
blocks_in_edit.sort_by_key(|(row, _, block)| (*row, block.disposition, block.id));
|
|
||||||
|
// When multiple blocks are on the same row, newer blocks appear above older
|
||||||
|
// blocks. This is arbitrary, but we currently rely on it in ProjectDiagnosticsEditor.
|
||||||
|
blocks_in_edit
|
||||||
|
.sort_by_key(|(row, _, block)| (*row, block.disposition, Reverse(block.id)));
|
||||||
|
|
||||||
// For each of these blocks, insert a new isomorphic transform preceding the block,
|
// For each of these blocks, insert a new isomorphic transform preceding the block,
|
||||||
// and then insert the block itself.
|
// and then insert the block itself.
|
||||||
|
@ -940,7 +944,11 @@ mod tests {
|
||||||
start_row..start_row + block.height(),
|
start_row..start_row + block.height(),
|
||||||
block.column(),
|
block.column(),
|
||||||
block
|
block
|
||||||
.render(&BlockContext { cx, anchor_x: 0., line_number_x: 0., })
|
.render(&BlockContext {
|
||||||
|
cx,
|
||||||
|
anchor_x: 0.,
|
||||||
|
line_number_x: 0.,
|
||||||
|
})
|
||||||
.name()
|
.name()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue