mirror of
https://github.com/typst/typst
synced 2025-05-15 17:45:27 +08:00
Precisely find label definition
This commit is contained in:
parent
8a7a4d154d
commit
4a60f26a22
@ -75,7 +75,10 @@ pub fn definition(
|
||||
let label = Label::new(PicoStr::intern(node.cast::<ast::Ref>()?.target()));
|
||||
let selector = Selector::Label(label);
|
||||
let elem = document?.introspector.query_first(&selector)?;
|
||||
return Some(Definition::Span(elem.span()));
|
||||
let labelled_at = elem.labelled_at().or(elem.span());
|
||||
if !labelled_at.is_detached() {
|
||||
return Some(Definition::Span(labelled_at));
|
||||
}
|
||||
}
|
||||
|
||||
_ => {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user