aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_vfs/src
diff options
context:
space:
mode:
authorBernardo <[email protected]>2019-01-16 18:30:20 +0000
committerAleksey Kladov <[email protected]>2019-01-26 08:46:27 +0000
commite69b620f0d1e90afcc14dc7cf07ed0b828d8ec96 (patch)
tree89a499f4cd50e1d1ebadbf8c7a9f0a5e777cbc7b /crates/ra_vfs/src
parentabd8ccefa4fd1abbf674f479f0dd7d0457c94d2d (diff)
add missing Task::HandleChange
Diffstat (limited to 'crates/ra_vfs/src')
-rw-r--r--crates/ra_vfs/src/io.rs11
-rw-r--r--crates/ra_vfs/src/lib.rs1
-rw-r--r--crates/ra_vfs/src/watcher.rs14
3 files changed, 16 insertions, 10 deletions
diff --git a/crates/ra_vfs/src/io.rs b/crates/ra_vfs/src/io.rs
index a0c87fb25..e5d5c6463 100644
--- a/crates/ra_vfs/src/io.rs
+++ b/crates/ra_vfs/src/io.rs
@@ -15,7 +15,8 @@ pub(crate) enum Task {
15 path: PathBuf, 15 path: PathBuf,
16 filter: Box<Fn(&DirEntry) -> bool + Send>, 16 filter: Box<Fn(&DirEntry) -> bool + Send>,
17 }, 17 },
18 LoadChange(crate::watcher::WatcherChange), 18 HandleChange(WatcherChange),
19 LoadChange(WatcherChange),
19} 20}
20 21
21#[derive(Debug)] 22#[derive(Debug)]
@@ -63,6 +64,10 @@ fn handle_task(task: Task) -> TaskResult {
63 log::debug!("... loaded {}", path.as_path().display()); 64 log::debug!("... loaded {}", path.as_path().display());
64 TaskResult::AddRoot(AddRootResult { root, files }) 65 TaskResult::AddRoot(AddRootResult { root, files })
65 } 66 }
67 Task::HandleChange(change) => {
68 // forward as is because Vfs has to decide if we should load it
69 TaskResult::HandleChange(change)
70 }
66 Task::LoadChange(change) => { 71 Task::LoadChange(change) => {
67 log::debug!("loading {:?} ...", change); 72 log::debug!("loading {:?} ...", change);
68 let data = load_change(change); 73 let data = load_change(change);
@@ -107,7 +112,7 @@ fn load_change(change: WatcherChange) -> Option<WatcherChangeData> {
107 let text = match fs::read_to_string(&path) { 112 let text = match fs::read_to_string(&path) {
108 Ok(text) => text, 113 Ok(text) => text,
109 Err(e) => { 114 Err(e) => {
110 log::warn!("watcher error: {}", e); 115 log::warn!("watcher error \"{}\": {}", path.display(), e);
111 return None; 116 return None;
112 } 117 }
113 }; 118 };
@@ -117,7 +122,7 @@ fn load_change(change: WatcherChange) -> Option<WatcherChangeData> {
117 let text = match fs::read_to_string(&path) { 122 let text = match fs::read_to_string(&path) {
118 Ok(text) => text, 123 Ok(text) => text,
119 Err(e) => { 124 Err(e) => {
120 log::warn!("watcher error: {}", e); 125 log::warn!("watcher error \"{}\": {}", path.display(), e);
121 return None; 126 return None;
122 } 127 }
123 }; 128 };
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs
index f698e3e86..48a46d210 100644
--- a/crates/ra_vfs/src/lib.rs
+++ b/crates/ra_vfs/src/lib.rs
@@ -266,6 +266,7 @@ impl Vfs {
266 if let Some(file) = file { 266 if let Some(file) = file {
267 if self.files[file].is_overlayed { 267 if self.files[file].is_overlayed {
268 // file is overlayed 268 // file is overlayed
269 log::debug!("skipping overlayed \"{}\"", path.display());
269 return false; 270 return false;
270 } 271 }
271 } 272 }
diff --git a/crates/ra_vfs/src/watcher.rs b/crates/ra_vfs/src/watcher.rs
index 3bd0e7da2..dfbbcbfe6 100644
--- a/crates/ra_vfs/src/watcher.rs
+++ b/crates/ra_vfs/src/watcher.rs
@@ -35,24 +35,24 @@ fn send_change_events(
35 // ignore 35 // ignore
36 } 36 }
37 DebouncedEvent::Rescan => { 37 DebouncedEvent::Rescan => {
38 sender.send(io::Task::LoadChange(WatcherChange::Rescan))?; 38 sender.send(io::Task::HandleChange(WatcherChange::Rescan))?;
39 } 39 }
40 DebouncedEvent::Create(path) => { 40 DebouncedEvent::Create(path) => {
41 sender.send(io::Task::LoadChange(WatcherChange::Create(path)))?; 41 sender.send(io::Task::HandleChange(WatcherChange::Create(path)))?;
42 } 42 }
43 DebouncedEvent::Write(path) => { 43 DebouncedEvent::Write(path) => {
44 sender.send(io::Task::LoadChange(WatcherChange::Write(path)))?; 44 sender.send(io::Task::HandleChange(WatcherChange::Write(path)))?;
45 } 45 }
46 DebouncedEvent::Remove(path) => { 46 DebouncedEvent::Remove(path) => {
47 sender.send(io::Task::LoadChange(WatcherChange::Remove(path)))?; 47 sender.send(io::Task::HandleChange(WatcherChange::Remove(path)))?;
48 } 48 }
49 DebouncedEvent::Rename(src, dst) => { 49 DebouncedEvent::Rename(src, dst) => {
50 sender.send(io::Task::LoadChange(WatcherChange::Remove(src)))?; 50 sender.send(io::Task::HandleChange(WatcherChange::Remove(src)))?;
51 sender.send(io::Task::LoadChange(WatcherChange::Create(dst)))?; 51 sender.send(io::Task::HandleChange(WatcherChange::Create(dst)))?;
52 } 52 }
53 DebouncedEvent::Error(err, path) => { 53 DebouncedEvent::Error(err, path) => {
54 // TODO should we reload the file contents? 54 // TODO should we reload the file contents?
55 log::warn!("watcher error {}, {:?}", err, path); 55 log::warn!("watcher error \"{}\", {:?}", err, path);
56 } 56 }
57 } 57 }
58 Ok(()) 58 Ok(())