editor: Fix incorrect hover popup row clamping (#41645)
Fixes ZED-2TR Fixes ZED-2TQ Fixes ZED-2TB Fixes ZED-2SW Fixes ZED-2SQ Release Notes: - Fixed panic in repainting hover popups Co-authored by: David <david@zed.dev>
This commit is contained in:
@@ -797,9 +797,18 @@ impl HoverState {
|
||||
})
|
||||
})?;
|
||||
let mut point = anchor.to_display_point(&snapshot.display_snapshot);
|
||||
|
||||
// Clamp the point within the visible rows in case the popup source spans multiple lines
|
||||
if point.row() < visible_rows.start {
|
||||
if visible_rows.end <= point.row() {
|
||||
point = crate::movement::up_by_rows(
|
||||
&snapshot.display_snapshot,
|
||||
point,
|
||||
1 + (point.row() - visible_rows.end).0,
|
||||
text::SelectionGoal::None,
|
||||
true,
|
||||
text_layout_details,
|
||||
)
|
||||
.0;
|
||||
} else if point.row() < visible_rows.start {
|
||||
point = crate::movement::down_by_rows(
|
||||
&snapshot.display_snapshot,
|
||||
point,
|
||||
@@ -809,16 +818,11 @@ impl HoverState {
|
||||
text_layout_details,
|
||||
)
|
||||
.0;
|
||||
} else if visible_rows.end <= point.row() {
|
||||
point = crate::movement::up_by_rows(
|
||||
&snapshot.display_snapshot,
|
||||
point,
|
||||
(visible_rows.end - point.row()).0,
|
||||
text::SelectionGoal::None,
|
||||
true,
|
||||
text_layout_details,
|
||||
)
|
||||
.0;
|
||||
}
|
||||
|
||||
if !visible_rows.contains(&point.row()) {
|
||||
log::error!("Hover popover point out of bounds after moving");
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut elements = Vec::new();
|
||||
|
||||
Reference in New Issue
Block a user