Fix flickering cursor style when a pane was zoomed (#8546)

Antonio Scandurra and Max Brunsfeld created

Release Notes:

- N/A

Co-authored-by: Max Brunsfeld <max@zed.dev>

Change summary

crates/editor/src/element.rs         | 9 +++++++--
crates/gpui/src/window/element_cx.rs | 2 +-
2 files changed, 8 insertions(+), 3 deletions(-)

Detailed changes

crates/editor/src/element.rs 🔗

@@ -716,6 +716,11 @@ impl EditorElement {
         let scroll_position = layout.position_map.snapshot.scroll_position();
         let scroll_top = scroll_position.y * line_height;
 
+        if bounds.contains(&cx.mouse_position()) {
+            let stacking_order = cx.stacking_order().clone();
+            cx.set_cursor_style(CursorStyle::Arrow, stacking_order);
+        }
+
         let show_git_gutter = matches!(
             ProjectSettings::get_global(cx).git.git_gutter,
             Some(GitGutterSetting::TrackedFiles)
@@ -915,7 +920,7 @@ impl EditorElement {
                     bounds: text_bounds,
                     stacking_order: cx.stacking_order().clone(),
                 };
-                if interactive_text_bounds.visibly_contains(&cx.mouse_position(), cx) {
+                if text_bounds.contains(&cx.mouse_position()) {
                     if self
                         .editor
                         .read(cx)
@@ -1557,7 +1562,7 @@ impl EditorElement {
             stacking_order: cx.stacking_order().clone(),
         };
         let mut mouse_position = cx.mouse_position();
-        if interactive_track_bounds.visibly_contains(&mouse_position, cx) {
+        if track_bounds.contains(&mouse_position) {
             cx.set_cursor_style(
                 CursorStyle::Arrow,
                 interactive_track_bounds.stacking_order.clone(),

crates/gpui/src/window/element_cx.rs 🔗

@@ -409,7 +409,7 @@ impl<'a> ElementContext<'a> {
             .requested_cursor_style
             .as_ref()
             .map_or(true, |prev_style_request| {
-                style_request.stacking_order > prev_style_request.stacking_order
+                style_request.stacking_order >= prev_style_request.stacking_order
             })
         {
             self.window.next_frame.requested_cursor_style = Some(style_request.clone());