aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/global_state.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-10 17:48:39 +0100
committerAleksey Kladov <[email protected]>2020-07-10 21:30:24 +0100
commit86bc4d20b30b8deb7783c200ad9f5d3acf019116 (patch)
treefa25cf01edc141a11405af52c5501e9209f01d5a /crates/rust-analyzer/src/global_state.rs
parentc1eed627d909e897309b3d50654a592505654147 (diff)
Also reload when adding new examples, tests, etc
Diffstat (limited to 'crates/rust-analyzer/src/global_state.rs')
-rw-r--r--crates/rust-analyzer/src/global_state.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index c8d34e15a..728dc9962 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -122,6 +122,9 @@ impl GlobalState {
122 } 122 }
123 123
124 pub(crate) fn process_changes(&mut self) -> bool { 124 pub(crate) fn process_changes(&mut self) -> bool {
125 let mut fs_changes = Vec::new();
126 let mut has_fs_changes = false;
127
125 let change = { 128 let change = {
126 let mut change = AnalysisChange::new(); 129 let mut change = AnalysisChange::new();
127 let (vfs, line_endings_map) = &mut *self.vfs.write(); 130 let (vfs, line_endings_map) = &mut *self.vfs.write();
@@ -130,13 +133,14 @@ impl GlobalState {
130 return false; 133 return false;
131 } 134 }
132 135
133 let fs_op = changed_files.iter().any(|it| it.is_created_or_deleted());
134 if fs_op {
135 let roots = self.source_root_config.partition(&vfs);
136 change.set_roots(roots)
137 }
138
139 for file in changed_files { 136 for file in changed_files {
137 if file.is_created_or_deleted() {
138 if let Some(path) = vfs.file_path(file.file_id).as_path() {
139 fs_changes.push((path.to_path_buf(), file.change_kind));
140 has_fs_changes = true;
141 }
142 }
143
140 let text = if file.exists() { 144 let text = if file.exists() {
141 let bytes = vfs.file_contents(file.file_id).to_vec(); 145 let bytes = vfs.file_contents(file.file_id).to_vec();
142 match String::from_utf8(bytes).ok() { 146 match String::from_utf8(bytes).ok() {
@@ -152,10 +156,15 @@ impl GlobalState {
152 }; 156 };
153 change.change_file(file.file_id, text); 157 change.change_file(file.file_id, text);
154 } 158 }
159 if has_fs_changes {
160 let roots = self.source_root_config.partition(&vfs);
161 change.set_roots(roots);
162 }
155 change 163 change
156 }; 164 };
157 165
158 self.analysis_host.apply_change(change); 166 self.analysis_host.apply_change(change);
167 self.maybe_refresh(&fs_changes);
159 true 168 true
160 } 169 }
161 170