use join_all to build partial symbols and completions asynchronously

This commit is contained in:
Isaac Clayton 2022-07-06 11:13:28 +02:00
parent 602fe14aa4
commit 0872e9b1a7

View file

@ -3311,7 +3311,6 @@ impl Project {
return Ok(Default::default());
};
// TODO(isaac): also use join_all
struct PartialSymbol {
source_worktree_id: WorktreeId,
worktree_id: WorktreeId,
@ -3366,6 +3365,7 @@ impl Project {
let mut symbols = Vec::new();
for ps in partial_symbols.into_iter() {
symbols.push(async move {
let label = match ps.language {
Some(language) => language.label_for_symbol(&ps.name, ps.kind).await,
None => None,
@ -3374,7 +3374,7 @@ impl Project {
let language_server_name = ps.adapter.name().await;
symbols.push(Symbol {
Symbol {
source_worktree_id: ps.source_worktree_id,
worktree_id: ps.worktree_id,
language_server_name,
@ -3384,10 +3384,11 @@ impl Project {
path: ps.path,
range: ps.range,
signature: ps.signature,
}
});
}
Ok(symbols)
Ok(futures::future::join_all(symbols).await)
})
} else if let Some(project_id) = self.remote_id() {
let request = self.client.request(proto::GetProjectSymbols {
@ -3678,6 +3679,7 @@ impl Project {
let mut result = Vec::new();
for pc in partial_completions.into_iter() {
result.push(async move {
let label = match pc.language.as_ref() {
Some(l) => l.label_for_completion(&pc.lsp_completion).await,
None => None,
@ -3696,10 +3698,11 @@ impl Project {
lsp_completion: pc.lsp_completion,
};
result.push(completion);
completion
});
}
Ok(result)
Ok(futures::future::join_all(result).await)
})
} else if let Some(project_id) = self.remote_id() {
let rpc = self.client.clone();