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

@ -562,7 +562,7 @@ impl DirectoryLister {
}
DirectoryLister::Local(fs) => {
let fs = fs.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let mut results = vec![];
let expanded = shellexpand::tilde(&path);
let query = Path::new(expanded.as_ref());
@ -1163,13 +1163,12 @@ impl Project {
.read(cx)
.shutdown_processes(Some(proto::ShutdownRemoteServer {}));
cx.background_executor()
.spawn(async move {
if let Some(shutdown) = shutdown {
shutdown.await;
}
})
.detach()
cx.background_spawn(async move {
if let Some(shutdown) = shutdown {
shutdown.await;
}
})
.detach()
}
match &self.client_state {
@ -3138,7 +3137,7 @@ impl Project {
let buffer = buffer.clone();
let query = query.clone();
let snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot())?;
chunk_results.push(cx.background_executor().spawn(async move {
chunk_results.push(cx.background_spawn(async move {
let ranges = query
.search(&snapshot, None)
.await
@ -3377,7 +3376,7 @@ impl Project {
cx: &mut Context<Self>,
) -> Task<Option<ResolvedPath>> {
let resolve_task = self.resolve_abs_path(path, cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let resolved_path = resolve_task.await;
resolved_path.filter(|path| path.is_file())
})
@ -3391,7 +3390,7 @@ impl Project {
if self.is_local() {
let expanded = PathBuf::from(shellexpand::tilde(&path).into_owned());
let fs = self.fs.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let path = expanded.as_path();
let metadata = fs.metadata(path).await.ok().flatten();
@ -3409,7 +3408,7 @@ impl Project {
project_id: SSH_PROJECT_ID,
path: request_path.to_proto(),
});
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let response = request.await.log_err()?;
if response.exists {
Some(ResolvedPath::AbsPath {
@ -3490,7 +3489,7 @@ impl Project {
};
let response = session.read(cx).proto_client().request(request);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let response = response.await?;
Ok(response.entries.into_iter().map(PathBuf::from).collect())
})
@ -3906,8 +3905,7 @@ impl Project {
if let Some(remote_id) = this.remote_id() {
let mut payload = envelope.payload.clone();
payload.project_id = remote_id;
cx.background_executor()
.spawn(this.client.request(payload))
cx.background_spawn(this.client.request(payload))
.detach_and_log_err(cx);
}
this.buffer_store.clone()
@ -3924,8 +3922,7 @@ impl Project {
if let Some(ssh) = &this.ssh_client {
let mut payload = envelope.payload.clone();
payload.project_id = SSH_PROJECT_ID;
cx.background_executor()
.spawn(ssh.read(cx).proto_client().request(payload))
cx.background_spawn(ssh.read(cx).proto_client().request(payload))
.detach_and_log_err(cx);
}
this.buffer_store.clone()
@ -4146,7 +4143,7 @@ impl Project {
if let Some(buffer) = this.buffer_for_id(buffer_id, cx) {
let operations =
buffer.read(cx).serialize_ops(Some(remote_version), cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let operations = operations.await;
for chunk in split_operations(operations) {
client
@ -4169,12 +4166,11 @@ impl Project {
// Any incomplete buffers have open requests waiting. Request that the host sends
// creates these buffers for us again to unblock any waiting futures.
for id in incomplete_buffer_ids {
cx.background_executor()
.spawn(client.request(proto::OpenBufferById {
project_id,
id: id.into(),
}))
.detach();
cx.background_spawn(client.request(proto::OpenBufferById {
project_id,
id: id.into(),
}))
.detach();
}
futures::future::join_all(send_updates_for_buffers)