aboutsummaryrefslogtreecommitdiff
path: root/crates/vfs/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/vfs/src/lib.rs')
-rw-r--r--crates/vfs/src/lib.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs
index cdf6f1fd0..9cf2afd33 100644
--- a/crates/vfs/src/lib.rs
+++ b/crates/vfs/src/lib.rs
@@ -36,6 +36,7 @@
36//! have a single `FileSet` which unions the two sources. 36//! have a single `FileSet` which unions the two sources.
37mod vfs_path; 37mod vfs_path;
38mod path_interner; 38mod path_interner;
39mod anchored_path;
39pub mod file_set; 40pub mod file_set;
40pub mod loader; 41pub mod loader;
41 42
@@ -43,7 +44,10 @@ use std::{fmt, mem};
43 44
44use crate::path_interner::PathInterner; 45use crate::path_interner::PathInterner;
45 46
46pub use crate::vfs_path::VfsPath; 47pub use crate::{
48 anchored_path::{AnchoredPath, AnchoredPathBuf},
49 vfs_path::VfsPath,
50};
47pub use paths::{AbsPath, AbsPathBuf}; 51pub use paths::{AbsPath, AbsPathBuf};
48 52
49#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] 53#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
@@ -99,18 +103,19 @@ impl Vfs {
99 (file_id, path) 103 (file_id, path)
100 }) 104 })
101 } 105 }
102 pub fn set_file_contents(&mut self, path: VfsPath, contents: Option<Vec<u8>>) { 106 pub fn set_file_contents(&mut self, path: VfsPath, contents: Option<Vec<u8>>) -> bool {
103 let file_id = self.alloc_file_id(path); 107 let file_id = self.alloc_file_id(path);
104 let change_kind = match (&self.get(file_id), &contents) { 108 let change_kind = match (&self.get(file_id), &contents) {
105 (None, None) => return, 109 (None, None) => return false,
106 (None, Some(_)) => ChangeKind::Create, 110 (None, Some(_)) => ChangeKind::Create,
107 (Some(_), None) => ChangeKind::Delete, 111 (Some(_), None) => ChangeKind::Delete,
108 (Some(old), Some(new)) if old == new => return, 112 (Some(old), Some(new)) if old == new => return false,
109 (Some(_), Some(_)) => ChangeKind::Modify, 113 (Some(_), Some(_)) => ChangeKind::Modify,
110 }; 114 };
111 115
112 *self.get_mut(file_id) = contents; 116 *self.get_mut(file_id) = contents;
113 self.changes.push(ChangedFile { file_id, change_kind }) 117 self.changes.push(ChangedFile { file_id, change_kind });
118 true
114 } 119 }
115 pub fn has_changes(&self) -> bool { 120 pub fn has_changes(&self) -> bool {
116 !self.changes.is_empty() 121 !self.changes.is_empty()