Resolve documents outside of the workspace

This commit is contained in:
Patrick Förster 2019-05-21 18:14:53 +02:00
parent bb18080f69
commit a44697aec4
2 changed files with 27 additions and 1 deletions

View file

@ -277,7 +277,10 @@ impl<C: LspClient + Send + Sync> jsonrpc::EventHandler for LatexLspServer<C> {
for event in self.event_manager.take() {
match event {
Event::WorkspaceChanged => {
log::info!("TODO: Workspace Changed");
let workspace = self.workspace_manager.get();
workspace.unresolved_includes()
.iter()
.for_each(|path| self.workspace_manager.load(&path));
}
}
}

View file

@ -133,6 +133,29 @@ impl Workspace {
}
None
}
pub fn unresolved_includes(&self) -> Vec<PathBuf> {
let mut includes = Vec::new();
for document in &self.documents {
if let SyntaxTree::Latex(tree) = &document.tree {
for include in &tree.includes {
if self.resolve_document(&document.uri, include).is_some() {
continue;
}
if let Some(targets) = Self::resolve_link_targets(&document.uri, &include) {
for target in &targets {
let path = PathBuf::from(target);
if path.exists() {
includes.push(path);
}
}
}
}
}
}
includes
}
}
pub struct WorkspaceManager {