diff --git a/crates/ty_test/src/hover.rs b/crates/ty_test/src/hover.rs index 386700b7ea..03e2b52192 100644 --- a/crates/ty_test/src/hover.rs +++ b/crates/ty_test/src/hover.rs @@ -26,10 +26,12 @@ pub(crate) struct HoverOutput { } /// Find the AST node with minimal range that fully contains the given offset. +/// Returns the smallest expression node if possible, skipping over identifier-only nodes. fn find_covering_node(root: AnyNodeRef<'_>, offset: TextSize) -> Option> { struct Visitor<'a> { offset: TextSize, minimal_node: Option>, + minimal_expr: Option>, } impl<'a> SourceOrderVisitor<'a> for Visitor<'a> { @@ -43,6 +45,18 @@ fn find_covering_node(root: AnyNodeRef<'_>, offset: TextSize) -> Option, offset: TextSize) -> Option