From be14ab217ce29542a8b2c84282e822adcc69646c Mon Sep 17 00:00:00 2001 From: Bernardo Date: Tue, 22 Jan 2019 18:38:34 +0100 Subject: better test, avoid duplicated events --- crates/ra_vfs/src/io/watcher.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'crates/ra_vfs/src/io') diff --git a/crates/ra_vfs/src/io/watcher.rs b/crates/ra_vfs/src/io/watcher.rs index b370c5fbc..68bb6b692 100644 --- a/crates/ra_vfs/src/io/watcher.rs +++ b/crates/ra_vfs/src/io/watcher.rs @@ -100,16 +100,18 @@ impl Watcher { log::warn!("could not watch \"{}\": {}", entry.path().display(), e) } } - } - if emit_for_contents && entry.depth() > 0 { - // emit as create because we haven't seen it yet - if let Err(e) = - self.sender - .send(io::Task::HandleChange(WatcherChange::Create( - entry.path().to_path_buf(), - ))) - { - log::warn!("watcher error: {}", e) + } else { + if emit_for_contents && entry.depth() > 0 { + // emit only for files otherwise we will cause watch_recursive to be called again with a dir that we are already watching + // emit as create because we haven't seen it yet + if let Err(e) = + self.sender + .send(io::Task::HandleChange(WatcherChange::Create( + entry.path().to_path_buf(), + ))) + { + log::warn!("watcher error: {}", e) + } } } } -- cgit v1.2.3