summaryrefslogtreecommitdiff
path: root/support/texlab/crates/base-db/src/workspace.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/crates/base-db/src/workspace.rs')
-rw-r--r--support/texlab/crates/base-db/src/workspace.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/support/texlab/crates/base-db/src/workspace.rs b/support/texlab/crates/base-db/src/workspace.rs
index 1afd4712e9..75674dcf8d 100644
--- a/support/texlab/crates/base-db/src/workspace.rs
+++ b/support/texlab/crates/base-db/src/workspace.rs
@@ -29,11 +29,22 @@ impl Workspace {
self.documents.get(key)
}
- pub fn lookup_path(&self, path: &Path) -> Option<&Document> {
+ pub fn lookup_file(&self, path: &Path) -> Option<&Document> {
self.iter()
.find(|document| document.path.as_deref() == Some(path))
}
+ pub fn lookup_file_or_dir<'a>(
+ &'a self,
+ file_or_dir: &'a Path,
+ ) -> impl Iterator<Item = &'a Document> + '_ {
+ self.iter().filter(move |doc| {
+ doc.path
+ .as_deref()
+ .map_or(false, |p| p.starts_with(file_or_dir))
+ })
+ }
+
pub fn iter(&self) -> impl Iterator<Item = &Document> + '_ {
self.documents.iter()
}
@@ -50,6 +61,10 @@ impl Workspace {
&self.graphs
}
+ pub fn folders(&self) -> &[PathBuf] {
+ &self.folders
+ }
+
pub fn open(
&mut self,
uri: Url,
@@ -90,7 +105,7 @@ impl Workspace {
Owner::Server
};
- if let Some(document) = self.lookup_path(path) {
+ if let Some(document) = self.lookup_file(path) {
if document.text == text {
return Ok(());
}
@@ -173,6 +188,7 @@ impl Workspace {
}
pub fn remove(&mut self, uri: &Url) {
+ log::info!("Removing moved or deleted document: {uri}");
self.documents.remove(uri);
}