Skip to content

Commit 3698b3e

Browse files
committed
Avoid duplicate cargo checks
1 parent 9ca5973 commit 3698b3e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! requests/replies and notifications back to the client.
33
use std::{
44
env, fmt,
5+
sync::Arc,
56
time::{Duration, Instant},
67
};
78

@@ -229,17 +230,23 @@ impl GlobalState {
229230
}
230231
ProjectWorkspaceProgress::End(workspaces) => {
231232
self.fetch_workspaces_completed(workspaces);
233+
234+
let old = Arc::clone(&self.workspaces);
232235
self.switch_workspaces();
233-
if self.config.run_build_scripts() {
236+
let workspaces_updated = !Arc::ptr_eq(&old, &self.workspaces);
237+
238+
if self.config.run_build_scripts() && workspaces_updated {
234239
let mut collector = BuildDataCollector::default();
235240
for ws in self.workspaces.iter() {
236241
ws.collect_build_data_configs(&mut collector);
237242
}
238243
self.fetch_build_data_request(collector)
239244
}
245+
240246
(Progress::End, None)
241247
}
242248
};
249+
243250
self.report_progress("fetching", state, msg, None);
244251
}
245252
Task::FetchBuildData(progress) => {
@@ -250,15 +257,19 @@ impl GlobalState {
250257
}
251258
BuildDataProgress::End(build_data_result) => {
252259
self.fetch_build_data_completed(build_data_result);
260+
253261
self.switch_workspaces();
262+
254263
(Some(Progress::End), None)
255264
}
256265
};
266+
257267
if let Some(state) = state {
258268
self.report_progress("loading", state, msg, None);
259269
}
260270
}
261271
}
272+
262273
// Coalesce multiple task events into one loop turn
263274
task = match self.task_pool.receiver.try_recv() {
264275
Ok(task) => task,

0 commit comments

Comments
 (0)