From 18db6f5efffcfec3054dcf2c573fdcaff42c697d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20F=C3=B6rster?= Date: Wed, 17 Aug 2022 19:33:12 +0200 Subject: [PATCH] Do not treat links to packages as bidirectional This commits fixes issues related to the project discovery where two separate projects reference the same local package or document class. See #679. --- src/workspace.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/workspace.rs b/src/workspace.rs index 57fbb141..1e4184a9 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -8,7 +8,7 @@ use anyhow::Result; use crossbeam_channel::Sender; use lsp_types::Url; use notify::Watcher; -use petgraph::{graphmap::UnGraphMap, visit::Dfs}; +use petgraph::{graphmap::DiGraphMap, visit::Dfs}; use rustc_hash::{FxHashMap, FxHashSet}; use crate::{ @@ -145,6 +145,14 @@ impl Workspace { for target in targets { if let Some(j) = all_uris.iter().position(|uri| uri == target) { edges.push((i, j, ())); + + if target.as_str().ends_with(".tex") + || target.as_str().ends_with(".bib") + || target.as_str().ends_with(".rnw") + { + edges.push((j, i, ())); + } + break; } } @@ -154,7 +162,7 @@ impl Workspace { let mut slice = self.clone(); slice.documents_by_uri = FxHashMap::default(); - let graph = UnGraphMap::from_edges(edges); + let graph = DiGraphMap::from_edges(edges); let mut dfs = Dfs::new(&graph, start); while let Some(i) = dfs.next(&graph) { let uri = &all_uris[i];