summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorMyriad-Dreamin <35292584+Myriad-Dreamin@users.noreply.github.com>2024-04-02 04:54:49 +0800
committerGitHub <noreply@github.com>2024-04-01 20:54:49 +0000
commit092f6dc462787f05d8f7d6b515bd66fb665c2272 (patch)
tree86c259b1e0a83a2d0b9ca72f44e8511a00ca1834 /crates
parentd672080e8517f28e15488210d6d3a5309a981bea (diff)
Fix source path resolution in import analysis (#3842)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst-ide/src/analyze.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/typst-ide/src/analyze.rs b/crates/typst-ide/src/analyze.rs
index 9d67b322..47214481 100644
--- a/crates/typst-ide/src/analyze.rs
+++ b/crates/typst-ide/src/analyze.rs
@@ -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)
}