Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Optimize render_markdown_block function (#28487)
Bennet Bo Fenner55760295d902
diff --git a/crates/agent/src/active_thread.rs b/crates/agent/src/active_thread.rsindex fcc119743ae..6c1b45f3e25 100644--- a/crates/agent/src/active_thread.rs+++ b/crates/agent/src/active_thread.rs@@ -467,12 +467,15 @@ fn render_markdown_code_block(.element_background.blend(cx.theme().colors().editor_foreground.opacity(0.01));- let line_count = without_fences(&parsed_markdown.source()[codeblock_range.clone()])- .lines()- .count();-+ const CODE_FENCES_LINE_COUNT: usize = 2;const MAX_COLLAPSED_LINES: usize = 5;+ let line_count = parsed_markdown.source()[codeblock_range.clone()]+ .bytes()+ .filter(|c| *c == b'\n')+ .count()+ .saturating_sub(CODE_FENCES_LINE_COUNT - 1);+let codeblock_header = h_flex().group("codeblock_header").p_1()