From e69b620f0d1e90afcc14dc7cf07ed0b828d8ec96 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Wed, 16 Jan 2019 19:30:20 +0100 Subject: add missing Task::HandleChange --- crates/ra_vfs/src/io.rs | 11 ++++++++--- crates/ra_vfs/src/lib.rs | 1 + crates/ra_vfs/src/watcher.rs | 14 +++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'crates/ra_vfs/src') 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 { path: PathBuf, filter: Box bool + Send>, }, - LoadChange(crate::watcher::WatcherChange), + HandleChange(WatcherChange), + LoadChange(WatcherChange), } #[derive(Debug)] @@ -63,6 +64,10 @@ fn handle_task(task: Task) -> TaskResult { log::debug!("... loaded {}", path.as_path().display()); TaskResult::AddRoot(AddRootResult { root, files }) } + Task::HandleChange(change) => { + // forward as is because Vfs has to decide if we should load it + TaskResult::HandleChange(change) + } Task::LoadChange(change) => { log::debug!("loading {:?} ...", change); let data = load_change(change); @@ -107,7 +112,7 @@ fn load_change(change: WatcherChange) -> Option { let text = match fs::read_to_string(&path) { Ok(text) => text, Err(e) => { - log::warn!("watcher error: {}", e); + log::warn!("watcher error \"{}\": {}", path.display(), e); return None; } }; @@ -117,7 +122,7 @@ fn load_change(change: WatcherChange) -> Option { let text = match fs::read_to_string(&path) { Ok(text) => text, Err(e) => { - log::warn!("watcher error: {}", e); + log::warn!("watcher error \"{}\": {}", path.display(), e); return None; } }; 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 { if let Some(file) = file { if self.files[file].is_overlayed { // file is overlayed + log::debug!("skipping overlayed \"{}\"", path.display()); return false; } } 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( // ignore } DebouncedEvent::Rescan => { - sender.send(io::Task::LoadChange(WatcherChange::Rescan))?; + sender.send(io::Task::HandleChange(WatcherChange::Rescan))?; } DebouncedEvent::Create(path) => { - sender.send(io::Task::LoadChange(WatcherChange::Create(path)))?; + sender.send(io::Task::HandleChange(WatcherChange::Create(path)))?; } DebouncedEvent::Write(path) => { - sender.send(io::Task::LoadChange(WatcherChange::Write(path)))?; + sender.send(io::Task::HandleChange(WatcherChange::Write(path)))?; } DebouncedEvent::Remove(path) => { - sender.send(io::Task::LoadChange(WatcherChange::Remove(path)))?; + sender.send(io::Task::HandleChange(WatcherChange::Remove(path)))?; } DebouncedEvent::Rename(src, dst) => { - sender.send(io::Task::LoadChange(WatcherChange::Remove(src)))?; - sender.send(io::Task::LoadChange(WatcherChange::Create(dst)))?; + sender.send(io::Task::HandleChange(WatcherChange::Remove(src)))?; + sender.send(io::Task::HandleChange(WatcherChange::Create(dst)))?; } DebouncedEvent::Error(err, path) => { // TODO should we reload the file contents? - log::warn!("watcher error {}, {:?}", err, path); + log::warn!("watcher error \"{}\", {:?}", err, path); } } Ok(()) -- cgit v1.2.3