diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_vfs/src/io/watcher.rs | 6 | ||||
-rw-r--r-- | crates/ra_vfs/src/lib.rs | 3 | ||||
-rw-r--r-- | crates/ra_vfs/tests/vfs.rs | 18 |
3 files changed, 16 insertions, 11 deletions
diff --git a/crates/ra_vfs/src/io/watcher.rs b/crates/ra_vfs/src/io/watcher.rs index 1d7ce2136..ff6775f59 100644 --- a/crates/ra_vfs/src/io/watcher.rs +++ b/crates/ra_vfs/src/io/watcher.rs | |||
@@ -65,7 +65,7 @@ impl Watcher { | |||
65 | { | 65 | { |
66 | match res { | 66 | match res { |
67 | Ok(entry) => { | 67 | Ok(entry) => { |
68 | if entry.path().is_dir() { | 68 | if entry.file_type().is_dir() { |
69 | watch_one(self.watcher.as_ref(), entry.path()); | 69 | watch_one(self.watcher.as_ref(), entry.path()); |
70 | } | 70 | } |
71 | } | 71 | } |
@@ -172,11 +172,11 @@ impl WatcherWorker { | |||
172 | let filter = &self.roots[root]; | 172 | let filter = &self.roots[root]; |
173 | for res in WalkDir::new(dir) | 173 | for res in WalkDir::new(dir) |
174 | .into_iter() | 174 | .into_iter() |
175 | .filter_entry(|entry| filter.can_contain(entry.path()).is_some()) | 175 | .filter_entry(filter.entry_filter()) |
176 | { | 176 | { |
177 | match res { | 177 | match res { |
178 | Ok(entry) => { | 178 | Ok(entry) => { |
179 | if entry.path().is_dir() { | 179 | if entry.file_type().is_dir() { |
180 | watch_one(self.watcher.as_ref(), entry.path()); | 180 | watch_one(self.watcher.as_ref(), entry.path()); |
181 | } else { | 181 | } else { |
182 | // emit only for files otherwise we will cause watch_recursive to be called again with a dir that we are already watching | 182 | // emit only for files otherwise we will cause watch_recursive to be called again with a dir that we are already watching |
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 661892f8a..d1b0222e7 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs | |||
@@ -62,7 +62,8 @@ impl RootFilter { | |||
62 | 62 | ||
63 | pub(crate) fn entry_filter<'a>(&'a self) -> impl FnMut(&DirEntry) -> bool + 'a { | 63 | pub(crate) fn entry_filter<'a>(&'a self) -> impl FnMut(&DirEntry) -> bool + 'a { |
64 | move |entry: &DirEntry| { | 64 | move |entry: &DirEntry| { |
65 | if entry.path().is_dir() && self.excluded_dirs.iter().any(|it| it == entry.path()) { | 65 | if entry.file_type().is_dir() && self.excluded_dirs.iter().any(|it| it == entry.path()) |
66 | { | ||
66 | // do not walk nested roots | 67 | // do not walk nested roots |
67 | false | 68 | false |
68 | } else { | 69 | } else { |
diff --git a/crates/ra_vfs/tests/vfs.rs b/crates/ra_vfs/tests/vfs.rs index 8562c56b9..357e1c775 100644 --- a/crates/ra_vfs/tests/vfs.rs +++ b/crates/ra_vfs/tests/vfs.rs | |||
@@ -1,12 +1,16 @@ | |||
1 | use std::{collections::HashSet, fs}; | 1 | use std::{collections::HashSet, fs, time::Duration}; |
2 | 2 | ||
3 | use flexi_logger::Logger; | 3 | // use flexi_logger::Logger; |
4 | use crossbeam_channel::RecvTimeoutError; | ||
4 | use ra_vfs::{Vfs, VfsChange}; | 5 | use ra_vfs::{Vfs, VfsChange}; |
5 | use tempfile::tempdir; | 6 | use tempfile::tempdir; |
6 | 7 | ||
7 | fn process_tasks(vfs: &mut Vfs, num_tasks: u32) { | 8 | fn process_tasks(vfs: &mut Vfs, num_tasks: u32) { |
8 | for _ in 0..num_tasks { | 9 | for _ in 0..num_tasks { |
9 | let task = vfs.task_receiver().recv().unwrap(); | 10 | let task = vfs |
11 | .task_receiver() | ||
12 | .recv_timeout(Duration::from_secs(3)) | ||
13 | .unwrap(); | ||
10 | log::debug!("{:?}", task); | 14 | log::debug!("{:?}", task); |
11 | vfs.handle_task(task); | 15 | vfs.handle_task(task); |
12 | } | 16 | } |
@@ -14,7 +18,7 @@ fn process_tasks(vfs: &mut Vfs, num_tasks: u32) { | |||
14 | 18 | ||
15 | macro_rules! assert_match { | 19 | macro_rules! assert_match { |
16 | ($x:expr, $pat:pat) => { | 20 | ($x:expr, $pat:pat) => { |
17 | assert_match!($x, $pat, assert!(true)) | 21 | assert_match!($x, $pat, ()) |
18 | }; | 22 | }; |
19 | ($x:expr, $pat:pat, $assert:expr) => { | 23 | ($x:expr, $pat:pat, $assert:expr) => { |
20 | match $x { | 24 | match $x { |
@@ -26,7 +30,7 @@ macro_rules! assert_match { | |||
26 | 30 | ||
27 | #[test] | 31 | #[test] |
28 | fn test_vfs_works() -> std::io::Result<()> { | 32 | fn test_vfs_works() -> std::io::Result<()> { |
29 | Logger::with_str("vfs=debug,ra_vfs=debug").start().unwrap(); | 33 | // Logger::with_str("vfs=debug,ra_vfs=debug").start().unwrap(); |
30 | 34 | ||
31 | let files = [ | 35 | let files = [ |
32 | ("a/foo.rs", "hello"), | 36 | ("a/foo.rs", "hello"), |
@@ -166,8 +170,8 @@ fn test_vfs_works() -> std::io::Result<()> { | |||
166 | fs::write(&dir.path().join("a/target/new.rs"), "ignore me").unwrap(); | 170 | fs::write(&dir.path().join("a/target/new.rs"), "ignore me").unwrap(); |
167 | 171 | ||
168 | assert_match!( | 172 | assert_match!( |
169 | vfs.task_receiver().try_recv(), | 173 | vfs.task_receiver().recv_timeout(Duration::from_millis(300)), // slightly more than watcher debounce delay |
170 | Err(crossbeam_channel::TryRecvError::Empty) | 174 | Err(RecvTimeoutError::Timeout) |
171 | ); | 175 | ); |
172 | 176 | ||
173 | vfs.shutdown().unwrap(); | 177 | vfs.shutdown().unwrap(); |