Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix Flashing Hover Popover (#8238)

ethana11ebe01fffb
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index cdcc8ed1cd7..099c52d7fd3 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -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;
diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs
index 8bed85305a5..fb65e35be73 100644
--- a/crates/editor/src/hover_popover.rs
+++ b/crates/editor/src/hover_popover.rs
@@ -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)
{