aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-17 17:54:11 +0000
committerAleksey Kladov <[email protected]>2019-02-17 17:54:11 +0000
commite8bc29f122813bb3c69d1f8cd60dd6ab4dd9a4bf (patch)
tree8aa4def850e5984bd72725995f420d432957f94a
parentb719a6cc07772f4c50fe34865e7dc82c4df11dfb (diff)
simplify overlay handling
-rw-r--r--crates/ra_vfs/src/lib.rs24
1 files changed, 8 insertions, 16 deletions
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs
index 1e1344456..ddbc38163 100644
--- a/crates/ra_vfs/src/lib.rs
+++ b/crates/ra_vfs/src/lib.rs
@@ -145,7 +145,7 @@ impl Vfs {
145 if let Ok(text) = fs::read_to_string(&full_path) { 145 if let Ok(text) = fs::read_to_string(&full_path) {
146 self.do_change_file(file, text, true); 146 self.do_change_file(file, text, true);
147 } else { 147 } else {
148 self.do_remove_file(root, rel_path, file, true); 148 self.do_remove_file(root, rel_path, file);
149 } 149 }
150 Some(file) 150 Some(file)
151 } 151 }
@@ -183,9 +183,13 @@ impl Vfs {
183 self.pending_changes.push(change); 183 self.pending_changes.push(change);
184 } 184 }
185 TaskResult::SingleFile { root, path, text } => { 185 TaskResult::SingleFile { root, path, text } => {
186 match (self.find_file(root, &path), text) { 186 let file = self.find_file(root, &path);
187 if file.map(|file| self.files[file].is_overlayed) == Some(true) {
188 return;
189 }
190 match (file, text) {
187 (Some(file), None) => { 191 (Some(file), None) => {
188 self.do_remove_file(root, path, file, false); 192 self.do_remove_file(root, path, file);
189 } 193 }
190 (None, Some(text)) => { 194 (None, Some(text)) => {
191 self.do_add_file(root, path, text, false); 195 self.do_add_file(root, path, text, false);
@@ -213,24 +217,12 @@ impl Vfs {
213 } 217 }
214 218
215 fn do_change_file(&mut self, file: VfsFile, text: String, is_overlay: bool) { 219 fn do_change_file(&mut self, file: VfsFile, text: String, is_overlay: bool) {
216 if !is_overlay && self.files[file].is_overlayed {
217 return;
218 }
219 let text = Arc::new(text); 220 let text = Arc::new(text);
220 self.change_file(file, text.clone(), is_overlay); 221 self.change_file(file, text.clone(), is_overlay);
221 self.pending_changes.push(VfsChange::ChangeFile { file, text }); 222 self.pending_changes.push(VfsChange::ChangeFile { file, text });
222 } 223 }
223 224
224 fn do_remove_file( 225 fn do_remove_file(&mut self, root: VfsRoot, path: RelativePathBuf, file: VfsFile) {
225 &mut self,
226 root: VfsRoot,
227 path: RelativePathBuf,
228 file: VfsFile,
229 is_overlay: bool,
230 ) {
231 if !is_overlay && self.files[file].is_overlayed {
232 return;
233 }
234 self.remove_file(file); 226 self.remove_file(file);
235 self.pending_changes.push(VfsChange::RemoveFile { root, path, file }); 227 self.pending_changes.push(VfsChange::RemoveFile { root, path, file });
236 } 228 }