diff options
Diffstat (limited to 'crates/ra_vfs')
-rw-r--r-- | crates/ra_vfs/src/io.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/ra_vfs/src/io.rs b/crates/ra_vfs/src/io.rs index 84ccdb394..279fa5da8 100644 --- a/crates/ra_vfs/src/io.rs +++ b/crates/ra_vfs/src/io.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | use std::{ | 1 | use std::{ |
2 | fs, | 2 | fs, |
3 | thread, | ||
3 | path::{Path, PathBuf}, | 4 | path::{Path, PathBuf}, |
4 | sync::{mpsc, Arc}, | 5 | sync::{mpsc, Arc}, |
5 | thread, | ||
6 | time::Duration, | 6 | time::Duration, |
7 | }; | 7 | }; |
8 | use crossbeam_channel::{Receiver, Sender, SendError}; | 8 | use crossbeam_channel::{Receiver, Sender}; |
9 | use relative_path::RelativePathBuf; | 9 | use relative_path::RelativePathBuf; |
10 | use thread_worker::WorkerHandle; | 10 | use thread_worker::WorkerHandle; |
11 | use walkdir::WalkDir; | 11 | use walkdir::WalkDir; |
@@ -14,6 +14,8 @@ use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher as _Watc | |||
14 | 14 | ||
15 | use crate::{RootConfig, Roots, VfsRoot}; | 15 | use crate::{RootConfig, Roots, VfsRoot}; |
16 | 16 | ||
17 | type Result<T> = std::result::Result<T, crossbeam_channel::SendError<TaskResult>>; | ||
18 | |||
17 | pub(crate) enum Task { | 19 | pub(crate) enum Task { |
18 | AddRoot { | 20 | AddRoot { |
19 | root: VfsRoot, | 21 | root: VfsRoot, |
@@ -112,11 +114,7 @@ impl Worker { | |||
112 | } | 114 | } |
113 | } | 115 | } |
114 | 116 | ||
115 | fn watch_root( | 117 | fn watch_root(woker: &WatcherCtx, root: VfsRoot, config: Arc<RootConfig>) -> Result<()> { |
116 | woker: &WatcherCtx, | ||
117 | root: VfsRoot, | ||
118 | config: Arc<RootConfig>, | ||
119 | ) -> Result<(), SendError<TaskResult>> { | ||
120 | let mut guard = woker.watcher.lock(); | 118 | let mut guard = woker.watcher.lock(); |
121 | log::debug!("loading {} ...", config.root.as_path().display()); | 119 | log::debug!("loading {} ...", config.root.as_path().display()); |
122 | let files = watch_recursive(guard.as_mut(), config.root.as_path(), &*config) | 120 | let files = watch_recursive(guard.as_mut(), config.root.as_path(), &*config) |
@@ -142,7 +140,7 @@ struct WatcherCtx { | |||
142 | } | 140 | } |
143 | 141 | ||
144 | impl WatcherCtx { | 142 | impl WatcherCtx { |
145 | fn handle_debounced_event(&self, ev: DebouncedEvent) -> Result<(), SendError<TaskResult>> { | 143 | fn handle_debounced_event(&self, ev: DebouncedEvent) -> Result<()> { |
146 | match ev { | 144 | match ev { |
147 | DebouncedEvent::NoticeWrite(_) | 145 | DebouncedEvent::NoticeWrite(_) |
148 | | DebouncedEvent::NoticeRemove(_) | 146 | | DebouncedEvent::NoticeRemove(_) |
@@ -173,7 +171,7 @@ impl WatcherCtx { | |||
173 | Ok(()) | 171 | Ok(()) |
174 | } | 172 | } |
175 | 173 | ||
176 | fn handle_change(&self, path: PathBuf, kind: ChangeKind) -> Result<(), SendError<TaskResult>> { | 174 | fn handle_change(&self, path: PathBuf, kind: ChangeKind) -> Result<()> { |
177 | let (root, rel_path) = match self.roots.find(&path) { | 175 | let (root, rel_path) = match self.roots.find(&path) { |
178 | None => return Ok(()), | 176 | None => return Ok(()), |
179 | Some(it) => it, | 177 | Some(it) => it, |