Move "async move" a few characters to the left in cx.spawn() (#26758)

This is the core change:
https://github.com/zed-industries/zed/pull/26758/files#diff-044302c0d57147af17e68a0009fee3e8dcdfb4f32c27a915e70cfa80e987f765R1052

TODO:
- [x] Use AsyncFn instead of Fn() -> Future in GPUI spawn methods
- [x] Implement it in the whole app
- [x] Implement it in the debugger 
- [x] Glance at the RPC crate, and see if those box future methods can
be switched over. Answer: It can't directly, as you can't make an
AsyncFn* into a trait object. There's ways around that, but they're all
more complex than just keeping the code as is.
- [ ] Fix platform specific code

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2025-03-18 19:09:02 -07:00 committed by GitHub
parent 7f2e3fb5bd
commit 1aefa5178b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
256 changed files with 3110 additions and 3200 deletions

View file

@ -129,7 +129,7 @@ impl PickerDelegate for ExtensionVersionSelectorDelegate {
})
.collect::<Vec<_>>();
cx.spawn_in(window, move |this, mut cx| async move {
cx.spawn_in(window, async move |this, cx| {
let matches = if query.is_empty() {
candidates
.into_iter()
@ -153,7 +153,7 @@ impl PickerDelegate for ExtensionVersionSelectorDelegate {
.await
};
this.update(&mut cx, |this, _cx| {
this.update(cx, |this, _cx| {
this.delegate.matches = matches;
this.delegate.selected_index = this
.delegate

View file

@ -77,14 +77,14 @@ pub fn init(cx: &mut App) {
let workspace_handle = cx.entity().downgrade();
window
.spawn(cx, |mut cx| async move {
.spawn(cx, async move |cx| {
let extension_path =
match Flatten::flatten(prompt.await.map_err(|e| e.into())) {
Ok(Some(mut paths)) => paths.pop()?,
Ok(None) => return None,
Err(err) => {
workspace_handle
.update(&mut cx, |workspace, cx| {
.update(cx, |workspace, cx| {
workspace.show_portal_error(err.to_string(), cx);
})
.ok();
@ -93,7 +93,7 @@ pub fn init(cx: &mut App) {
};
let install_task = store
.update(&mut cx, |store, cx| {
.update(cx, |store, cx| {
store.install_dev_extension(extension_path, cx)
})
.ok()?;
@ -102,7 +102,7 @@ pub fn init(cx: &mut App) {
Ok(_) => {}
Err(err) => {
workspace_handle
.update(&mut cx, |workspace, cx| {
.update(cx, |workspace, cx| {
workspace.show_error(
&err.context("failed to install dev extension"),
cx,
@ -399,7 +399,7 @@ impl ExtensionsPage {
store.fetch_extensions(search.as_deref(), provides_filter.as_ref(), cx)
});
cx.spawn(move |this, mut cx| async move {
cx.spawn(async move |this, cx| {
let dev_extensions = if let Some(search) = search {
let match_candidates = dev_extensions
.iter()
@ -425,7 +425,7 @@ impl ExtensionsPage {
};
let fetch_result = remote_extensions.await;
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
cx.notify();
this.dev_extension_entries = dev_extensions;
this.is_fetching_extensions = false;
@ -768,8 +768,8 @@ impl ExtensionsPage {
return;
};
cx.spawn_in(window, move |this, mut cx| async move {
let extension_versions_task = this.update(&mut cx, |_, cx| {
cx.spawn_in(window, async move |this, cx| {
let extension_versions_task = this.update(cx, |_, cx| {
let extension_store = ExtensionStore::global(cx);
extension_store.update(cx, |store, cx| {
@ -779,7 +779,7 @@ impl ExtensionsPage {
let extension_versions = extension_versions_task.await?;
workspace.update_in(&mut cx, |workspace, window, cx| {
workspace.update_in(cx, |workspace, window, cx| {
let fs = workspace.project().read(cx).fs().clone();
workspace.toggle_modal(window, cx, |window, cx| {
let delegate = ExtensionVersionSelectorDelegate::new(
@ -969,9 +969,9 @@ impl ExtensionsPage {
}
fn fetch_extensions_debounced(&mut self, cx: &mut Context<ExtensionsPage>) {
self.extension_fetch_task = Some(cx.spawn(|this, mut cx| async move {
self.extension_fetch_task = Some(cx.spawn(async move |this, cx| {
let search = this
.update(&mut cx, |this, cx| this.search_query(cx))
.update(cx, |this, cx| this.search_query(cx))
.ok()
.flatten();
@ -987,7 +987,7 @@ impl ExtensionsPage {
.await;
};
this.update(&mut cx, |this, cx| {
this.update(cx, |this, cx| {
this.fetch_extensions(search, Some(BTreeSet::from_iter(this.provides_filter)), cx);
})
.ok();