rustdoc: Don't start indexing if a crate is already being indexed (#13149)

This PR updates the rustdoc indexing to not start indexing a crate that
is already being indexed.

Currently the indexing of a crate might get continuously interrupted by
the user's typing, resulting in thrashing of the indexing task and never
indexing the crate in its entirety.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-06-17 11:52:05 -04:00 committed by GitHub
parent 16fce64d3a
commit 0c28b6a11a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -89,6 +89,10 @@ impl RustdocStore {
crate_name: CrateName,
provider: Box<dyn RustdocProvider + Send + Sync + 'static>,
) -> Shared<Task<Result<(), Arc<anyhow::Error>>>> {
if let Some(existing_task) = self.indexing_tasks_by_crate.read().get(&crate_name) {
return existing_task.clone();
}
let indexing_task = self
.executor
.spawn({