cx.background_executor().spawn(...) -> cx.background_spawn(...) (#25103)

Done automatically with

> ast-grep -p '$A.background_executor().spawn($B)' -r
'$A.background_spawn($B)' --update-all --globs "\!crates/gpui"

Followed by:

* `cargo fmt`
* Unexpected need to remove some trailing whitespace.
* Manually adding imports of `gpui::{AppContext as _}` which provides
`background_spawn`
* Added `AppContext as _` to existing use of `AppContext`

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-02-18 13:30:33 -07:00 committed by GitHub
parent f606b0641e
commit b1872e3afd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
120 changed files with 1146 additions and 1267 deletions

View file

@ -2144,7 +2144,7 @@ impl LocalLspStore {
cx: &mut Context<LspStore>,
) -> Task<Result<Vec<(Range<Anchor>, String)>>> {
let snapshot = self.buffer_snapshot_for_lsp_version(buffer, server_id, version, cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let snapshot = snapshot?;
let mut lsp_edits = lsp_edits
.into_iter()
@ -3282,16 +3282,15 @@ impl LspStore {
}
} else if let Some((upstream_client, upstream_project_id)) = self.upstream_client() {
let buffer_id = buffer.read(cx).remote_id().to_proto();
cx.background_executor()
.spawn(async move {
upstream_client
.request(proto::RegisterBufferWithLanguageServers {
project_id: upstream_project_id,
buffer_id,
})
.await
})
.detach();
cx.background_spawn(async move {
upstream_client
.request(proto::RegisterBufferWithLanguageServers {
project_id: upstream_project_id,
buffer_id,
})
.await
})
.detach();
} else {
panic!("oops!");
}
@ -6707,7 +6706,7 @@ impl LspStore {
return Err(anyhow!("No language server {id}"));
};
Ok(cx.background_executor().spawn(async move {
Ok(cx.background_spawn(async move {
let can_resolve = server
.capabilities()
.completion_provider
@ -7375,9 +7374,7 @@ impl LspStore {
.map(|b| b.read(cx).remote_id().to_proto())
.collect(),
});
cx.background_executor()
.spawn(request)
.detach_and_log_err(cx);
cx.background_spawn(request).detach_and_log_err(cx);
} else {
let Some(local) = self.as_local_mut() else {
return;
@ -7406,9 +7403,7 @@ impl LspStore {
.collect::<Vec<_>>();
cx.spawn(|this, mut cx| async move {
cx.background_executor()
.spawn(futures::future::join_all(tasks))
.await;
cx.background_spawn(futures::future::join_all(tasks)).await;
this.update(&mut cx, |this, cx| {
for buffer in buffers {
this.register_buffer_with_language_servers(&buffer, true, cx);
@ -7737,9 +7732,7 @@ impl LspStore {
},
)),
});
cx.background_executor()
.spawn(request)
.detach_and_log_err(cx);
cx.background_spawn(request).detach_and_log_err(cx);
} else if let Some(local) = self.as_local() {
let servers = buffers
.into_iter()
@ -7795,9 +7788,7 @@ impl LspStore {
),
),
});
cx.background_executor()
.spawn(request)
.detach_and_log_err(cx);
cx.background_spawn(request).detach_and_log_err(cx);
}
}