Clean up inline assist editor rendering (#15536)
Release Notes: - N/A --------- Co-authored-by: Nathan <nathan@zed.dev> Co-authored-by: Max <max@zed.dev>
This commit is contained in:
co-authored by
Nathan
Max
parent
73d8370177
commit
5b1ea7eda0
+27
-15
@@ -160,9 +160,9 @@ use workspace::{OpenInTerminal, OpenTerminal, TabBarSettings, Toast};
|
||||
use crate::hover_links::find_url;
|
||||
use crate::signature_help::{SignatureHelpHiddenBy, SignatureHelpState};
|
||||
|
||||
pub const FILE_HEADER_HEIGHT: u8 = 1;
|
||||
pub const MULTI_BUFFER_EXCERPT_HEADER_HEIGHT: u8 = 1;
|
||||
pub const MULTI_BUFFER_EXCERPT_FOOTER_HEIGHT: u8 = 1;
|
||||
pub const FILE_HEADER_HEIGHT: u32 = 1;
|
||||
pub const MULTI_BUFFER_EXCERPT_HEADER_HEIGHT: u32 = 1;
|
||||
pub const MULTI_BUFFER_EXCERPT_FOOTER_HEIGHT: u32 = 1;
|
||||
pub const DEFAULT_MULTIBUFFER_CONTEXT: u32 = 2;
|
||||
const CURSOR_BLINK_INTERVAL: Duration = Duration::from_millis(500);
|
||||
const MAX_LINE_LEN: usize = 1024;
|
||||
@@ -558,7 +558,7 @@ pub struct Editor {
|
||||
tasks: BTreeMap<(BufferId, BufferRow), RunnableTasks>,
|
||||
tasks_update_task: Option<Task<()>>,
|
||||
previous_search_ranges: Option<Arc<[Range<Anchor>]>>,
|
||||
file_header_size: u8,
|
||||
file_header_size: u32,
|
||||
breadcrumb_header: Option<String>,
|
||||
focused_block: Option<FocusedBlock>,
|
||||
}
|
||||
@@ -9805,14 +9805,11 @@ impl Editor {
|
||||
for (block_id, diagnostic) in &active_diagnostics.blocks {
|
||||
new_styles.insert(
|
||||
*block_id,
|
||||
(
|
||||
None,
|
||||
diagnostic_block_renderer(diagnostic.clone(), None, true, is_valid),
|
||||
),
|
||||
diagnostic_block_renderer(diagnostic.clone(), None, true, is_valid),
|
||||
);
|
||||
}
|
||||
self.display_map.update(cx, |display_map, cx| {
|
||||
display_map.replace_blocks(new_styles, cx)
|
||||
self.display_map.update(cx, |display_map, _cx| {
|
||||
display_map.replace_blocks(new_styles)
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -9855,7 +9852,7 @@ impl Editor {
|
||||
.insert_blocks(
|
||||
diagnostic_group.iter().map(|entry| {
|
||||
let diagnostic = entry.diagnostic.clone();
|
||||
let message_height = diagnostic.message.matches('\n').count() as u8 + 1;
|
||||
let message_height = diagnostic.message.matches('\n').count() as u32 + 1;
|
||||
BlockProperties {
|
||||
style: BlockStyle::Fixed,
|
||||
position: buffer.anchor_after(entry.range.start),
|
||||
@@ -10170,19 +10167,34 @@ impl Editor {
|
||||
blocks
|
||||
}
|
||||
|
||||
pub fn replace_blocks(
|
||||
pub(crate) fn resize_blocks(
|
||||
&mut self,
|
||||
blocks: HashMap<CustomBlockId, (Option<u8>, RenderBlock)>,
|
||||
heights: HashMap<CustomBlockId, u32>,
|
||||
autoscroll: Option<Autoscroll>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
self.display_map
|
||||
.update(cx, |display_map, cx| display_map.replace_blocks(blocks, cx));
|
||||
.update(cx, |display_map, cx| display_map.resize_blocks(heights, cx));
|
||||
if let Some(autoscroll) = autoscroll {
|
||||
self.request_autoscroll(autoscroll, cx);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_blocks(
|
||||
&mut self,
|
||||
renderers: HashMap<CustomBlockId, RenderBlock>,
|
||||
autoscroll: Option<Autoscroll>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
self.display_map
|
||||
.update(cx, |display_map, _cx| display_map.replace_blocks(renderers));
|
||||
if let Some(autoscroll) = autoscroll {
|
||||
self.request_autoscroll(autoscroll, cx);
|
||||
} else {
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_blocks(
|
||||
&mut self,
|
||||
block_ids: HashSet<CustomBlockId>,
|
||||
@@ -11755,7 +11767,7 @@ impl Editor {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn file_header_size(&self) -> u8 {
|
||||
pub fn file_header_size(&self) -> u32 {
|
||||
self.file_header_size
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user