aboutsummaryrefslogtreecommitdiff
path: root/crates/vfs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-12-09 16:29:34 +0000
committerJonas Schievink <[email protected]>2020-12-09 16:30:46 +0000
commit6857989f6f5c399857cddd54598eb2c8cb427e26 (patch)
tree7e812577ff0116ae303b1bb2b710ffd8e19cc352 /crates/vfs
parent42be522c80cf0cc2d49b60f3c1d66afdc51fcbbb (diff)
Fix "no value set for FileTextQuery(FileId(..))"
Diffstat (limited to 'crates/vfs')
-rw-r--r--crates/vfs/src/lib.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs
index cdf6f1fd0..a2c6a3400 100644
--- a/crates/vfs/src/lib.rs
+++ b/crates/vfs/src/lib.rs
@@ -99,18 +99,19 @@ impl Vfs {
99 (file_id, path) 99 (file_id, path)
100 }) 100 })
101 } 101 }
102 pub fn set_file_contents(&mut self, path: VfsPath, contents: Option<Vec<u8>>) { 102 pub fn set_file_contents(&mut self, path: VfsPath, contents: Option<Vec<u8>>) -> bool {
103 let file_id = self.alloc_file_id(path); 103 let file_id = self.alloc_file_id(path);
104 let change_kind = match (&self.get(file_id), &contents) { 104 let change_kind = match (&self.get(file_id), &contents) {
105 (None, None) => return, 105 (None, None) => return false,
106 (None, Some(_)) => ChangeKind::Create, 106 (None, Some(_)) => ChangeKind::Create,
107 (Some(_), None) => ChangeKind::Delete, 107 (Some(_), None) => ChangeKind::Delete,
108 (Some(old), Some(new)) if old == new => return, 108 (Some(old), Some(new)) if old == new => return false,
109 (Some(_), Some(_)) => ChangeKind::Modify, 109 (Some(_), Some(_)) => ChangeKind::Modify,
110 }; 110 };
111 111
112 *self.get_mut(file_id) = contents; 112 *self.get_mut(file_id) = contents;
113 self.changes.push(ChangedFile { file_id, change_kind }) 113 self.changes.push(ChangedFile { file_id, change_kind });
114 true
114 } 115 }
115 pub fn has_changes(&self) -> bool { 116 pub fn has_changes(&self) -> bool {
116 !self.changes.is_empty() 117 !self.changes.is_empty()