From ea26a01f5f2315b5770cd9dc475e843ee8ebc1b6 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 12 Jul 2024 11:31:52 +0300 Subject: [PATCH] Do not render a signature popover when its location is before the visible range (#14307) Follow-up of https://github.com/zed-industries/zed/pull/12909 Release Notes: - N/A --- crates/editor/src/element.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index cf9093ab57bfcf0e51df54716e0307eb80e06227..e12005f16db99447d66df606f6497e205addf834 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2642,28 +2642,30 @@ impl EditorElement { hitbox: &Hitbox, content_origin: gpui::Point, scroll_pixel_position: gpui::Point, - display_point: Option, + newest_selection_head: Option, start_row: DisplayRow, line_layouts: &[LineWithInvisibles], line_height: Pixels, em_width: Pixels, cx: &mut WindowContext, ) { - let Some(display_point) = display_point else { + let Some(newest_selection_head) = newest_selection_head else { return; }; - - let Some(cursor_row_layout) = - line_layouts.get(display_point.row().minus(start_row) as usize) + let selection_row = newest_selection_head.row(); + if selection_row < start_row { + return; + } + let Some(cursor_row_layout) = line_layouts.get(selection_row.minus(start_row) as usize) else { return; }; - let start_x = cursor_row_layout.x_for_index(display_point.column() as usize) + let start_x = cursor_row_layout.x_for_index(newest_selection_head.column() as usize) - scroll_pixel_position.x + content_origin.x; let start_y = - display_point.row().as_f32() * line_height + content_origin.y - scroll_pixel_position.y; + selection_row.as_f32() * line_height + content_origin.y - scroll_pixel_position.y; let max_size = size( (120. * em_width) // Default size