aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_vfs/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_vfs/src/lib.rs')
-rw-r--r--crates/ra_vfs/src/lib.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs
index 4de07b093..90d5e21f4 100644
--- a/crates/ra_vfs/src/lib.rs
+++ b/crates/ra_vfs/src/lib.rs
@@ -2,11 +2,13 @@
2//! 2//!
3//! When doing analysis, we don't want to do any IO, we want to keep all source 3//! When doing analysis, we don't want to do any IO, we want to keep all source
4//! code in memory. However, the actual source code is stored on disk, so you 4//! code in memory. However, the actual source code is stored on disk, so you
5//! component which does this.
6//! need to get it into the memory in the first place somehow. VFS is the 5//! need to get it into the memory in the first place somehow. VFS is the
6//! component which does this.
7//! 7//!
8//! It also is responsible for watching the disk for changes, and for merging 8//! It is also responsible for watching the disk for changes, and for merging
9//! editor state (modified, unsaved files) with disk state. 9//! editor state (modified, unsaved files) with disk state.
10//! TODO: Some LSP clients support watching the disk, so this crate should
11//! to support custom watcher events (related to https://github.com/rust-analyzer/rust-analyzer/issues/131)
10//! 12//!
11//! VFS is based on a concept of roots: a set of directories on the file system 13//! VFS is based on a concept of roots: a set of directories on the file system
12//! whihc are watched for changes. Typically, there will be a root for each 14//! whihc are watched for changes. Typically, there will be a root for each
@@ -29,7 +31,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
29use relative_path::RelativePathBuf; 31use relative_path::RelativePathBuf;
30use crossbeam_channel::Receiver; 32use crossbeam_channel::Receiver;
31use walkdir::DirEntry; 33use walkdir::DirEntry;
32use thread_worker::{WorkerHandle}; 34use thread_worker::WorkerHandle;
33 35
34use crate::{ 36use crate::{
35 arena::{ArenaId, Arena}, 37 arena::{ArenaId, Arena},
@@ -57,12 +59,8 @@ impl RootFilter {
57 if !(self.file_filter)(path) { 59 if !(self.file_filter)(path) {
58 return None; 60 return None;
59 } 61 }
60 if !(path.starts_with(&self.root)) { 62 let path = path.strip_prefix(&self.root).ok()?;
61 return None; 63 RelativePathBuf::from_path(path).ok()
62 }
63 let path = path.strip_prefix(&self.root).unwrap();
64 let path = RelativePathBuf::from_path(path).unwrap();
65 Some(path)
66 } 64 }
67} 65}
68 66