mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-04 10:18:16 +00:00
fix: deadlock when iterating dependencies (#568)
This commit is contained in:
parent
c6da5590ca
commit
9f9c710906
5 changed files with 22 additions and 12 deletions
|
@ -166,7 +166,7 @@ pub trait AnalysisResources {
|
|||
fn resolve(&self, spec: &PackageSpec) -> Result<Arc<Path>, PackageError>;
|
||||
|
||||
/// Get all the files in the workspace.
|
||||
fn iter_dependencies(&self, f: &mut dyn FnMut(ImmutPath));
|
||||
fn dependencies(&self) -> EcoVec<ImmutPath>;
|
||||
|
||||
/// Resolve extra font information.
|
||||
fn font_info(&self, _font: Font) -> Option<Arc<DataSource>> {
|
||||
|
|
|
@ -94,12 +94,11 @@ impl<'a, 'w> ReferencesWorker<'a, 'w> {
|
|||
fn label_root(mut self) -> Option<Vec<LspLocation>> {
|
||||
let mut ids = vec![];
|
||||
|
||||
// Collect ids first to avoid deadlocks
|
||||
self.ctx.ctx.resources.iter_dependencies(&mut |path| {
|
||||
if let Ok(ref_fid) = self.ctx.ctx.file_id_by_path(&path) {
|
||||
for dep in self.ctx.ctx.resources.dependencies() {
|
||||
if let Ok(ref_fid) = self.ctx.ctx.file_id_by_path(&dep) {
|
||||
ids.push(ref_fid);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for ref_fid in ids {
|
||||
self.file(ref_fid)?;
|
||||
|
|
|
@ -38,9 +38,9 @@ impl SemanticRequest for SymbolRequest {
|
|||
|
||||
// todo! need compilation for iter_dependencies
|
||||
|
||||
ctx.resources.iter_dependencies(&mut |path| {
|
||||
for path in ctx.resources.dependencies() {
|
||||
let Ok(source) = ctx.source_by_path(&path) else {
|
||||
return;
|
||||
continue;
|
||||
};
|
||||
let uri = path_to_url(&path).unwrap();
|
||||
let res =
|
||||
|
@ -57,7 +57,7 @@ impl SemanticRequest for SymbolRequest {
|
|||
if let Some(mut res) = res {
|
||||
symbols.append(&mut res)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Some(symbols)
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use std::{
|
|||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use ecow::EcoVec;
|
||||
use once_cell::sync::Lazy;
|
||||
use reflexo_typst::config::CompileOpts;
|
||||
use reflexo_typst::package::{PackageRegistry, PackageSpec};
|
||||
|
@ -40,8 +41,13 @@ impl<'a> AnalysisResources for WrapWorld<'a> {
|
|||
self.0.registry.resolve(spec)
|
||||
}
|
||||
|
||||
fn iter_dependencies(&self, f: &mut dyn FnMut(reflexo::ImmutPath)) {
|
||||
self.0.iter_dependencies(f)
|
||||
fn dependencies(&self) -> EcoVec<reflexo::ImmutPath> {
|
||||
let mut v = EcoVec::new();
|
||||
self.0.iter_dependencies(&mut |p| {
|
||||
v.push(p);
|
||||
});
|
||||
|
||||
v
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -215,9 +215,14 @@ impl CompileHandler {
|
|||
self.0.registry.resolve(spec)
|
||||
}
|
||||
|
||||
fn iter_dependencies(&self, f: &mut dyn FnMut(ImmutPath)) {
|
||||
fn dependencies(&self) -> EcoVec<ImmutPath> {
|
||||
use reflexo_typst::WorldDeps;
|
||||
self.0.iter_dependencies(f)
|
||||
let mut deps = EcoVec::new();
|
||||
self.0.iter_dependencies(&mut |dep| {
|
||||
deps.push(dep);
|
||||
});
|
||||
|
||||
deps
|
||||
}
|
||||
|
||||
/// Resolve extra font information.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue