aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/reload.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-02-12 14:58:29 +0000
committerFlorian Diebold <[email protected]>2021-02-12 15:31:16 +0000
commita7387cae2ca9d5e114246e6fada98bfe7808e1d0 (patch)
treedb0fe8d939afaa10929debf317be670f79909c9f /crates/rust-analyzer/src/reload.rs
parentdee5aba43a1b45131bf31268431fa71923f2ef2a (diff)
Fix slow tests sometimes failing
In some situations we reloaded the workspace in the tests after having reported to be ready. There's two fixes here: 1. Add a version to the VFS config and include that version in progress reports, so that we don't think we're done prematurely; 2. Delay status transitions until after changes are applied. Otherwise the last change during loading can potentially trigger a workspace reload, if it contains interesting changes.
Diffstat (limited to 'crates/rust-analyzer/src/reload.rs')
-rw-r--r--crates/rust-analyzer/src/reload.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index c4f1d098b..c07efa330 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -50,6 +50,16 @@ impl GlobalState {
50 Status::Loading | Status::NeedsReload => return, 50 Status::Loading | Status::NeedsReload => return,
51 Status::Ready { .. } | Status::Invalid => (), 51 Status::Ready { .. } | Status::Invalid => (),
52 } 52 }
53 log::info!(
54 "Reloading workspace because of the following changes: {}",
55 itertools::join(
56 changes
57 .iter()
58 .filter(|(path, kind)| is_interesting(path, *kind))
59 .map(|(path, kind)| format!("{}/{:?}", path.display(), kind)),
60 ", "
61 )
62 );
53 if self.config.cargo_autoreload() { 63 if self.config.cargo_autoreload() {
54 self.fetch_workspaces_request(); 64 self.fetch_workspaces_request();
55 } else { 65 } else {
@@ -290,7 +300,12 @@ impl GlobalState {
290 FilesWatcher::Client => vec![], 300 FilesWatcher::Client => vec![],
291 FilesWatcher::Notify => project_folders.watch, 301 FilesWatcher::Notify => project_folders.watch,
292 }; 302 };
293 self.loader.handle.set_config(vfs::loader::Config { load: project_folders.load, watch }); 303 self.vfs_config_version += 1;
304 self.loader.handle.set_config(vfs::loader::Config {
305 load: project_folders.load,
306 watch,
307 version: self.vfs_config_version,
308 });
294 309
295 // Create crate graph from all the workspaces 310 // Create crate graph from all the workspaces
296 let crate_graph = { 311 let crate_graph = {