Release Notes:
- Use an inclusive range for local range containment check to match LSP
behavior & fix popover flashing while the cursor moves over the last
character of a symbol.
https://github.com/zed-industries/zed/assets/17223924/6c3ddc9c-04fb-4414-812f-025ede5ecaf7
@@ -894,6 +894,7 @@ impl EditorElement {
cx: &mut ElementContext,
) {
let start_row = layout.visible_display_row_range.start;
+ // Offset the content_bounds from the text_bounds by the gutter margin (which is roughly half a character wide) to make hit testing work more like how we want.
let content_origin =
text_bounds.origin + point(layout.gutter_dimensions.margin, Pixels::ZERO);
let line_end_overshoot = 0.15 * layout.position_map.line_height;
@@ -199,9 +199,10 @@ fn show_hover(
if symbol_range
.as_text_range()
.map(|range| {
- range- .to_offset(&snapshot.buffer_snapshot)- .contains(&multibuffer_offset)
+ let hover_range = range.to_offset(&snapshot.buffer_snapshot);
+ // LSP returns a hover result for the end index of ranges that should be hovered, so we need to
+ // use an inclusive range here to check if we should dismiss the popover
+ (hover_range.start..=hover_range.end).contains(&multibuffer_offset)
})
.unwrap_or(false)
{