aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_vfs/src
diff options
context:
space:
mode:
authorBernardo <[email protected]>2019-01-22 17:38:34 +0000
committerAleksey Kladov <[email protected]>2019-01-26 08:46:27 +0000
commitbe14ab217ce29542a8b2c84282e822adcc69646c (patch)
tree99fd4d871d7b14eca6604cab9f6648584d23b6f0 /crates/ra_vfs/src
parent0a086508524bed87bb15113437e9c2b1e1be4c42 (diff)
better test, avoid duplicated events
Diffstat (limited to 'crates/ra_vfs/src')
-rw-r--r--crates/ra_vfs/src/io.rs7
-rw-r--r--crates/ra_vfs/src/io/watcher.rs22
2 files changed, 18 insertions, 11 deletions
diff --git a/crates/ra_vfs/src/io.rs b/crates/ra_vfs/src/io.rs
index 3ab52ac3d..335f4f2e1 100644
--- a/crates/ra_vfs/src/io.rs
+++ b/crates/ra_vfs/src/io.rs
@@ -55,7 +55,12 @@ pub enum TaskResult {
55 55
56impl fmt::Debug for TaskResult { 56impl fmt::Debug for TaskResult {
57 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 57 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
58 f.write_str("TaskResult { ... }") 58 match self {
59 TaskResult::AddRoot(..) => f.write_str("TaskResult::AddRoot(..)"),
60 TaskResult::HandleChange(c) => write!(f, "TaskResult::HandleChange({:?})", c),
61 TaskResult::LoadChange(c) => write!(f, "TaskResult::LoadChange({:?})", c),
62 TaskResult::NoOp => f.write_str("TaskResult::NoOp"),
63 }
59 } 64 }
60} 65}
61 66
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 {
100 log::warn!("could not watch \"{}\": {}", entry.path().display(), e) 100 log::warn!("could not watch \"{}\": {}", entry.path().display(), e)
101 } 101 }
102 } 102 }
103 } 103 } else {
104 if emit_for_contents && entry.depth() > 0 { 104 if emit_for_contents && entry.depth() > 0 {
105 // emit as create because we haven't seen it yet 105 // emit only for files otherwise we will cause watch_recursive to be called again with a dir that we are already watching
106 if let Err(e) = 106 // emit as create because we haven't seen it yet
107 self.sender 107 if let Err(e) =
108 .send(io::Task::HandleChange(WatcherChange::Create( 108 self.sender
109 entry.path().to_path_buf(), 109 .send(io::Task::HandleChange(WatcherChange::Create(
110 ))) 110 entry.path().to_path_buf(),
111 { 111 )))
112 log::warn!("watcher error: {}", e) 112 {
113 log::warn!("watcher error: {}", e)
114 }
113 } 115 }
114 } 116 }
115 } 117 }