From c2b254a67a1dfa92e4201a8000078d7379a03665 Mon Sep 17 00:00:00 2001 From: Stanislav Alekseev <43210583+WeetHet@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:01:14 +0300 Subject: [PATCH] Fallback to using tree-sitter when determining ranges for info popovers (#16062) Closes #15382 Release Notes: - Added fallback to a smallest tree sitter node when hovering over a symbol --- crates/editor/src/hover_popover.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index 678830ac392a4..4e01806081705 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -398,6 +398,14 @@ fn show_hover( Some(start..end) }) + .or_else(|| { + let snapshot = &snapshot.buffer_snapshot; + let offset_range = snapshot.range_for_syntax_ancestor(anchor..anchor)?; + Some( + snapshot.anchor_before(offset_range.start) + ..snapshot.anchor_after(offset_range.end), + ) + }) .unwrap_or_else(|| anchor..anchor); let blocks = hover_result.contents;