mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Fix source path resolution in import analysis (#3842)
This commit is contained in:
parent
d007df3ecc
commit
b4885930d3
@ -50,6 +50,9 @@ pub fn analyze_expr(
|
||||
|
||||
/// Try to load a module from the current source file.
|
||||
pub fn analyze_import(world: &dyn World, source: &LinkedNode) -> Option<Value> {
|
||||
// Use span in the node for resolving imports with relative paths.
|
||||
let source_span = source.span();
|
||||
|
||||
let (source, _) = analyze_expr(world, source).into_iter().next()?;
|
||||
if source.scope().is_some() {
|
||||
return Some(source);
|
||||
@ -73,7 +76,7 @@ pub fn analyze_import(world: &dyn World, source: &LinkedNode) -> Option<Value> {
|
||||
Scopes::new(Some(world.library())),
|
||||
Span::detached(),
|
||||
);
|
||||
typst::eval::import(&mut vm, source, Span::detached(), true)
|
||||
typst::eval::import(&mut vm, source, source_span, true)
|
||||
.ok()
|
||||
.map(Value::Module)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user