Find first hovered ancestor expression

This commit is contained in:
Laurenz 2023-01-29 00:24:54 +01:00
parent 18e2aa2cea
commit ec21927d08

View File

@ -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() {