diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-01-29 00:24:54 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-01-29 00:24:54 +0100 |
| commit | ec21927d08d380c2b760a152c821910d57475ff2 (patch) | |
| tree | 7d0ed24299b827d8b9ea3a15f95fd0e2af63574d /src/ide | |
| parent | 18e2aa2cea9e89558683c95d050febef63c4af53 (diff) | |
Find first hovered ancestor expression
Diffstat (limited to 'src/ide')
| -rw-r--r-- | src/ide/tooltip.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ide/tooltip.rs b/src/ide/tooltip.rs index 4a03e5b8..26fa3625 100644 --- a/src/ide/tooltip.rs +++ b/src/ide/tooltip.rs @@ -32,12 +32,17 @@ pub enum Tooltip { /// Tooltip for a hovered expression. fn expr_tooltip(world: &(dyn World + 'static), leaf: &LinkedNode) -> Option<Tooltip> { - let expr = leaf.cast::<ast::Expr>()?; + let mut ancestor = leaf; + while !ancestor.is::<ast::Expr>() { + ancestor = ancestor.parent()?; + } + + let expr = ancestor.cast::<ast::Expr>()?; if !expr.hashtag() { return None; } - let values = analyze(world, leaf); + let values = analyze(world, ancestor); if let [value] = values.as_slice() { if let Some(docs) = value.docs() { |
