Skip to content

Commit

Permalink
Resolve documents outside of the workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed May 21, 2019
1 parent bb18080 commit a44697a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a44697a

Please sign in to comment.