From 64b15d3a0e1ce22390f042a67aae03cd109d9d71 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 24 Jul 2024 17:23:20 +0300 Subject: [PATCH] Display blocks over the git hunks (#15083) Before: ![before](https://github.com/user-attachments/assets/614bbafd-f344-4c86-bd62-fff5f1ab143a) After: ![after](https://github.com/user-attachments/assets/40a72a46-9fc4-4f94-9090-fb389f824a8d) Release Notes: - N/A --- crates/editor/src/element.rs | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 1897bbd6f01d9c355df37bbc86e3185042f530ec..1d1387bd70b2664613731060edf58d32fa5ae898 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1951,16 +1951,20 @@ impl EditorElement { .x_for_index(align_to.column() as usize) }; - block.render(&mut BlockContext { - context: cx, - anchor_x, - gutter_dimensions, - line_height, - em_width, - block_id, - max_width: text_hitbox.size.width.max(*scroll_width), - editor_style: &self.style, - }) + div() + .size_full() + .child(block.render(&mut BlockContext { + context: cx, + anchor_x, + gutter_dimensions, + line_height, + em_width, + block_id, + max_width: text_hitbox.size.width.max(*scroll_width), + editor_style: &self.style, + })) + .on_mouse_down(MouseButton::Left, |_, cx| cx.stop_propagation()) + .into_any_element() } Block::ExcerptHeader { @@ -5568,17 +5572,17 @@ impl Element for EditorElement { self.paint_text(layout, cx); + if layout.gutter_hitbox.size.width > Pixels::ZERO { + self.paint_gutter_highlights(layout, cx); + self.paint_gutter_indicators(layout, cx); + } + if !layout.blocks.is_empty() { cx.with_element_namespace("blocks", |cx| { self.paint_blocks(layout, cx); }); } - if layout.gutter_hitbox.size.width > Pixels::ZERO { - self.paint_gutter_highlights(layout, cx); - self.paint_gutter_indicators(layout, cx); - } - self.paint_scrollbar(layout, cx); self.paint_mouse_context_menu(layout, cx); });