From 7f7c4e7465f58cdbfdaaf232d571960f1b754b7c Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 21 Jan 2019 18:37:46 +0100 Subject: do not emit create for directory again --- crates/ra_vfs/src/io.rs | 7 ++++--- crates/ra_vfs/src/watcher.rs | 4 ++-- crates/ra_vfs/tests/vfs.rs | 3 --- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/ra_vfs/src/io.rs b/crates/ra_vfs/src/io.rs index 25acec9b1..a74222c02 100644 --- a/crates/ra_vfs/src/io.rs +++ b/crates/ra_vfs/src/io.rs @@ -68,11 +68,11 @@ impl Worker { let watcher_clone = watcher.clone(); let (worker, worker_handle) = thread_worker::spawn("vfs", 128, move |input_receiver, output_sender| { - let res = input_receiver + input_receiver .into_iter() .map(|t| handle_task(t, &watcher_clone)) - .try_for_each(|it| output_sender.send(it)); - res.unwrap() + .try_for_each(|it| output_sender.send(it)) + .unwrap() }); match Watcher::start(worker.inp.clone()) { Ok(w) => { @@ -99,6 +99,7 @@ impl Worker { if let Some(watcher) = self.watcher.lock().take() { let _ = watcher.shutdown(); } + let _ = self.worker.shutdown(); self.worker_handle.shutdown() } } diff --git a/crates/ra_vfs/src/watcher.rs b/crates/ra_vfs/src/watcher.rs index d8c35f2a3..606935891 100644 --- a/crates/ra_vfs/src/watcher.rs +++ b/crates/ra_vfs/src/watcher.rs @@ -87,7 +87,7 @@ impl Watcher { &mut self, dir: &Path, filter_entry: impl Fn(&DirEntry) -> bool, - emit_for_existing: bool, + emit_for_contents: bool, ) { for res in WalkDir::new(dir).into_iter().filter_entry(filter_entry) { match res { @@ -98,7 +98,7 @@ impl Watcher { Err(e) => log::warn!("could not watch \"{}\": {}", dir.display(), e), } } - if emit_for_existing { + if emit_for_contents && entry.depth() > 0 { // emit as create because we haven't seen it yet if let Err(e) = self.sender diff --git a/crates/ra_vfs/tests/vfs.rs b/crates/ra_vfs/tests/vfs.rs index 71b25a5c9..b18ea74a3 100644 --- a/crates/ra_vfs/tests/vfs.rs +++ b/crates/ra_vfs/tests/vfs.rs @@ -40,9 +40,6 @@ fn test_vfs_works() -> std::io::Result<()> { fs::write(file_path, text)? } - let gitignore = dir.path().join("a/.gitignore"); - fs::write(gitignore, "/target").unwrap(); - let a_root = dir.path().join("a"); let b_root = dir.path().join("a/b"); -- cgit v1.2.3