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:
Lukas Wirth
2025-10-31 14:24:23 +00:00
committed by GitHub
parent 1f938c08d2
commit c6d61870e2
2 changed files with 23 additions and 17 deletions
+16 -12
View File
@@ -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();