From e30449e61a712377c81873edde203def7fd0f24e Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 8 Nov 2023 14:28:16 +0100 Subject: [PATCH] Pass text_bounds instead of full editor bounds into mouse_moved. Co-authored-by: Antonio --- crates/editor2/src/element.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/crates/editor2/src/element.rs b/crates/editor2/src/element.rs index 0a590fe2fdb8ec8d017461fe36dfd490c714ce49..24277521ffb43ee8913b37b649f9935115e6f246 100644 --- a/crates/editor2/src/element.rs +++ b/crates/editor2/src/element.rs @@ -2763,6 +2763,14 @@ impl Element for EditorElement { cx: &mut gpui::ViewContext, ) { let layout = self.compute_layout(editor, cx, bounds); + let gutter_bounds = Bounds { + origin: bounds.origin, + size: layout.gutter_size, + }; + let text_bounds = Bounds { + origin: gutter_bounds.upper_right(), + size: layout.text_size, + }; cx.on_mouse_event({ let position_map = layout.position_map.clone(); @@ -2783,7 +2791,7 @@ impl Element for EditorElement { return; } - if Self::mouse_moved(editor, event, &position_map, bounds, cx) { + if Self::mouse_moved(editor, event, &position_map, text_bounds, cx) { cx.stop_propagation() } } @@ -2794,15 +2802,6 @@ impl Element for EditorElement { } cx.with_content_mask(ContentMask { bounds }, |cx| { - let gutter_bounds = Bounds { - origin: bounds.origin, - size: layout.gutter_size, - }; - let text_bounds = Bounds { - origin: gutter_bounds.upper_right(), - size: layout.text_size, - }; - self.paint_background(gutter_bounds, text_bounds, &layout, cx); if layout.gutter_size.width > Pixels::ZERO { self.paint_gutter(gutter_bounds, &layout, editor, cx);