diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-12 13:06:16 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-12 13:06:16 +0000 |
commit | a36e310229f13d6959d6ce95c99b659700cefc9a (patch) | |
tree | 7544c935fd8a3e0fa49ecebd3a684ddac4fed685 /crates/ra_vfs/src/lib.rs | |
parent | 19718ea109eae2f933ce3464c73879c09f9bdbe2 (diff) | |
parent | 7820fb38f439cf7eec94b668095ed32ae155c02f (diff) |
Merge #805
805: don't distinguish Create and Write events in VFS r=pnkfelix a=matklad
r? @pnkfelix
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_vfs/src/lib.rs')
-rw-r--r-- | crates/ra_vfs/src/lib.rs | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 3805be570..5d98d905c 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs | |||
@@ -37,8 +37,8 @@ impl_arena_id!(VfsRoot); | |||
37 | 37 | ||
38 | /// Describes the contents of a single source root. | 38 | /// Describes the contents of a single source root. |
39 | /// | 39 | /// |
40 | /// `RootConfig` can be thought of as a glob pattern like `src/**.rs` whihc | 40 | /// `RootConfig` can be thought of as a glob pattern like `src/**.rs` which |
41 | /// specifes the source root or as a function whihc takes a `PathBuf` and | 41 | /// specifies the source root or as a function which takes a `PathBuf` and |
42 | /// returns `true` iff path belongs to the source root | 42 | /// returns `true` iff path belongs to the source root |
43 | pub(crate) struct RootConfig { | 43 | pub(crate) struct RootConfig { |
44 | root: PathBuf, | 44 | root: PathBuf, |
@@ -60,7 +60,7 @@ impl RootConfig { | |||
60 | fn new(root: PathBuf, excluded_dirs: Vec<PathBuf>) -> RootConfig { | 60 | fn new(root: PathBuf, excluded_dirs: Vec<PathBuf>) -> RootConfig { |
61 | RootConfig { root, excluded_dirs } | 61 | RootConfig { root, excluded_dirs } |
62 | } | 62 | } |
63 | /// Cheks if root contains a path and returns a root-relative path. | 63 | /// Checks if root contains a path and returns a root-relative path. |
64 | pub(crate) fn contains(&self, path: &Path) -> Option<RelativePathBuf> { | 64 | pub(crate) fn contains(&self, path: &Path) -> Option<RelativePathBuf> { |
65 | // First, check excluded dirs | 65 | // First, check excluded dirs |
66 | if self.excluded_dirs.iter().any(|it| path.starts_with(it)) { | 66 | if self.excluded_dirs.iter().any(|it| path.starts_with(it)) { |
@@ -210,7 +210,7 @@ impl Vfs { | |||
210 | match task { | 210 | match task { |
211 | TaskResult::BulkLoadRoot { root, files } => { | 211 | TaskResult::BulkLoadRoot { root, files } => { |
212 | let mut cur_files = Vec::new(); | 212 | let mut cur_files = Vec::new(); |
213 | // While we were scanning the root in the backgound, a file might have | 213 | // While we were scanning the root in the background, a file might have |
214 | // been open in the editor, so we need to account for that. | 214 | // been open in the editor, so we need to account for that. |
215 | let exising = self.root2files[root] | 215 | let exising = self.root2files[root] |
216 | .iter() | 216 | .iter() |
@@ -230,21 +230,18 @@ impl Vfs { | |||
230 | let change = VfsChange::AddRoot { root, files: cur_files }; | 230 | let change = VfsChange::AddRoot { root, files: cur_files }; |
231 | self.pending_changes.push(change); | 231 | self.pending_changes.push(change); |
232 | } | 232 | } |
233 | TaskResult::AddSingleFile { root, path, text } => { | 233 | TaskResult::SingleFile { root, path, text } => { |
234 | if self.find_file(root, &path).is_none() { | 234 | match (self.find_file(root, &path), text) { |
235 | self.do_add_file(root, path, text, false); | 235 | (Some(file), None) => { |
236 | } | 236 | self.do_remove_file(root, path, file, false); |
237 | } | 237 | } |
238 | TaskResult::ChangeSingleFile { root, path, text } => { | 238 | (None, Some(text)) => { |
239 | if let Some(file) = self.find_file(root, &path) { | 239 | self.do_add_file(root, path, text, false); |
240 | self.do_change_file(file, text, false); | 240 | } |
241 | } else { | 241 | (Some(file), Some(text)) => { |
242 | self.do_add_file(root, path, text, false); | 242 | self.do_change_file(file, text, false); |
243 | } | 243 | } |
244 | } | 244 | (None, None) => (), |
245 | TaskResult::RemoveSingleFile { root, path } => { | ||
246 | if let Some(file) = self.find_file(root, &path) { | ||
247 | self.do_remove_file(root, path, file, false); | ||
248 | } | 245 | } |
249 | } | 246 | } |
250 | } | 247 | } |