aboutsummaryrefslogtreecommitdiff
path: root/crates/vfs/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-09 16:32:03 +0000
committerGitHub <[email protected]>2020-12-09 16:32:03 +0000
commit243ba330dd962f2d65cf1c8321e5e7d8ba01f03a (patch)
tree2c01572399f17d37851f67595e5271b2e25afc14 /crates/vfs/src
parent99118eeccdf6564876bbe6ec0672b04ffcbe3442 (diff)
parent6857989f6f5c399857cddd54598eb2c8cb427e26 (diff)
Merge #6785
6785: Fix "no value set for FileTextQuery(FileId(..))" r=jonas-schievink a=jonas-schievink Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6622 Let's hope I got it right this time, but I feel like I slowly begin to understand the main loop logic. bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/vfs/src')
-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 a3be579a7..9cf2afd33 100644
--- a/crates/vfs/src/lib.rs
+++ b/crates/vfs/src/lib.rs
@@ -103,18 +103,19 @@ impl Vfs {
103 (file_id, path) 103 (file_id, path)
104 }) 104 })
105 } 105 }
106 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 {
107 let file_id = self.alloc_file_id(path); 107 let file_id = self.alloc_file_id(path);
108 let change_kind = match (&self.get(file_id), &contents) { 108 let change_kind = match (&self.get(file_id), &contents) {
109 (None, None) => return, 109 (None, None) => return false,
110 (None, Some(_)) => ChangeKind::Create, 110 (None, Some(_)) => ChangeKind::Create,
111 (Some(_), None) => ChangeKind::Delete, 111 (Some(_), None) => ChangeKind::Delete,
112 (Some(old), Some(new)) if old == new => return, 112 (Some(old), Some(new)) if old == new => return false,
113 (Some(_), Some(_)) => ChangeKind::Modify, 113 (Some(_), Some(_)) => ChangeKind::Modify,
114 }; 114 };
115 115
116 *self.get_mut(file_id) = contents; 116 *self.get_mut(file_id) = contents;
117 self.changes.push(ChangedFile { file_id, change_kind }) 117 self.changes.push(ChangedFile { file_id, change_kind });
118 true
118 } 119 }
119 pub fn has_changes(&self) -> bool { 120 pub fn has_changes(&self) -> bool {
120 !self.changes.is_empty() 121 !self.changes.is_empty()