mirror of
https://github.com/typst/typst
synced 2025-05-13 12:36:23 +08:00
Find first hovered ancestor expression
This commit is contained in:
parent
18e2aa2cea
commit
ec21927d08
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user