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:
parent
7f2e3fb5bd
commit
1aefa5178b
256 changed files with 3110 additions and 3200 deletions
|
@ -145,11 +145,11 @@ impl FileFinder {
|
|||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
cx.spawn_in(window, move |workspace, mut cx| async move {
|
||||
cx.spawn_in(window, async move |workspace, cx| {
|
||||
let history_items = join_all(history_items).await.into_iter().flatten();
|
||||
|
||||
workspace
|
||||
.update_in(&mut cx, |workspace, window, cx| {
|
||||
.update_in(cx, |workspace, window, cx| {
|
||||
let project = workspace.project().clone();
|
||||
let weak_workspace = cx.entity().downgrade();
|
||||
workspace.toggle_modal(window, cx, |window, cx| {
|
||||
|
@ -738,7 +738,7 @@ impl FileFinderDelegate {
|
|||
self.cancel_flag.store(true, atomic::Ordering::Relaxed);
|
||||
self.cancel_flag = Arc::new(AtomicBool::new(false));
|
||||
let cancel_flag = self.cancel_flag.clone();
|
||||
cx.spawn_in(window, |picker, mut cx| async move {
|
||||
cx.spawn_in(window, async move |picker, cx| {
|
||||
let matches = fuzzy::match_path_sets(
|
||||
candidate_sets.as_slice(),
|
||||
query.path_query(),
|
||||
|
@ -753,7 +753,7 @@ impl FileFinderDelegate {
|
|||
.map(ProjectPanelOrdMatch);
|
||||
let did_cancel = cancel_flag.load(atomic::Ordering::Relaxed);
|
||||
picker
|
||||
.update(&mut cx, |picker, cx| {
|
||||
.update(cx, |picker, cx| {
|
||||
picker
|
||||
.delegate
|
||||
.set_search_matches(search_id, did_cancel, query, matches, cx)
|
||||
|
@ -983,9 +983,9 @@ impl FileFinderDelegate {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Picker<Self>>,
|
||||
) -> Task<()> {
|
||||
cx.spawn_in(window, |picker, mut cx| async move {
|
||||
cx.spawn_in(window, async move |picker, cx| {
|
||||
let Some(project) = picker
|
||||
.update(&mut cx, |picker, _| picker.delegate.project.clone())
|
||||
.update(cx, |picker, _| picker.delegate.project.clone())
|
||||
.log_err()
|
||||
else {
|
||||
return;
|
||||
|
@ -994,7 +994,7 @@ impl FileFinderDelegate {
|
|||
let query_path = Path::new(query.path_query());
|
||||
let mut path_matches = Vec::new();
|
||||
|
||||
let abs_file_exists = if let Ok(task) = project.update(&mut cx, |this, cx| {
|
||||
let abs_file_exists = if let Ok(task) = project.update(cx, |this, cx| {
|
||||
this.resolve_abs_file_path(query.path_query(), cx)
|
||||
}) {
|
||||
task.await.is_some()
|
||||
|
@ -1004,7 +1004,7 @@ impl FileFinderDelegate {
|
|||
|
||||
if abs_file_exists {
|
||||
let update_result = project
|
||||
.update(&mut cx, |project, cx| {
|
||||
.update(cx, |project, cx| {
|
||||
if let Some((worktree, relative_path)) =
|
||||
project.find_worktree(query_path, cx)
|
||||
{
|
||||
|
@ -1026,7 +1026,7 @@ impl FileFinderDelegate {
|
|||
}
|
||||
|
||||
picker
|
||||
.update_in(&mut cx, |picker, _, cx| {
|
||||
.update_in(cx, |picker, _, cx| {
|
||||
let picker_delegate = &mut picker.delegate;
|
||||
let search_id = util::post_inc(&mut picker_delegate.search_count);
|
||||
picker_delegate.set_search_matches(search_id, false, query, path_matches, cx);
|
||||
|
@ -1284,13 +1284,13 @@ impl PickerDelegate for FileFinderDelegate {
|
|||
.saturating_sub(1);
|
||||
let finder = self.file_finder.clone();
|
||||
|
||||
cx.spawn_in(window, |_, mut cx| async move {
|
||||
let item = open_task.await.notify_async_err(&mut cx)?;
|
||||
cx.spawn_in(window, async move |_, cx| {
|
||||
let item = open_task.await.notify_async_err(cx)?;
|
||||
if let Some(row) = row {
|
||||
if let Some(active_editor) = item.downcast::<Editor>() {
|
||||
active_editor
|
||||
.downgrade()
|
||||
.update_in(&mut cx, |editor, window, cx| {
|
||||
.update_in(cx, |editor, window, cx| {
|
||||
editor.go_to_singleton_buffer_point(
|
||||
Point::new(row, col),
|
||||
window,
|
||||
|
@ -1300,7 +1300,7 @@ impl PickerDelegate for FileFinderDelegate {
|
|||
.log_err();
|
||||
}
|
||||
}
|
||||
finder.update(&mut cx, |_, cx| cx.emit(DismissEvent)).ok()?;
|
||||
finder.update(cx, |_, cx| cx.emit(DismissEvent)).ok()?;
|
||||
|
||||
Some(())
|
||||
})
|
||||
|
|
|
@ -312,7 +312,7 @@ impl PickerDelegate for NewPathDelegate {
|
|||
let cancel_flag = self.cancel_flag.clone();
|
||||
let query = query.to_string();
|
||||
let prefix = dir.clone();
|
||||
cx.spawn_in(window, |picker, mut cx| async move {
|
||||
cx.spawn_in(window, async move |picker, cx| {
|
||||
let matches = fuzzy::match_path_sets(
|
||||
candidate_sets.as_slice(),
|
||||
&dir,
|
||||
|
@ -328,7 +328,7 @@ impl PickerDelegate for NewPathDelegate {
|
|||
return;
|
||||
}
|
||||
picker
|
||||
.update(&mut cx, |picker, cx| {
|
||||
.update(cx, |picker, cx| {
|
||||
picker
|
||||
.delegate
|
||||
.set_search_matches(query, prefix, suffix, matches, cx)
|
||||
|
@ -378,10 +378,10 @@ impl PickerDelegate for NewPathDelegate {
|
|||
&["Replace", "Cancel"],
|
||||
cx);
|
||||
let m = m.clone();
|
||||
cx.spawn_in(window, |picker, mut cx| async move {
|
||||
cx.spawn_in(window, async move |picker, cx| {
|
||||
let answer = answer.await.ok();
|
||||
picker
|
||||
.update(&mut cx, |picker, cx| {
|
||||
.update(cx, |picker, cx| {
|
||||
picker.delegate.should_dismiss = true;
|
||||
if answer != Some(0) {
|
||||
return;
|
||||
|
|
|
@ -161,14 +161,14 @@ impl PickerDelegate for OpenPathDelegate {
|
|||
self.cancel_flag = Arc::new(AtomicBool::new(false));
|
||||
let cancel_flag = self.cancel_flag.clone();
|
||||
|
||||
cx.spawn_in(window, |this, mut cx| async move {
|
||||
cx.spawn_in(window, async move |this, cx| {
|
||||
if let Some(query) = query {
|
||||
let paths = query.await;
|
||||
if cancel_flag.load(atomic::Ordering::Relaxed) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.update(&mut cx, |this, _| {
|
||||
this.update(cx, |this, _| {
|
||||
this.delegate.directory_state = Some(match paths {
|
||||
Ok(mut paths) => {
|
||||
paths.sort_by(|a, b| compare_paths((&a.path, true), (&b.path, true)));
|
||||
|
@ -201,7 +201,7 @@ impl PickerDelegate for OpenPathDelegate {
|
|||
}
|
||||
|
||||
let match_candidates = this
|
||||
.update(&mut cx, |this, cx| {
|
||||
.update(cx, |this, cx| {
|
||||
let directory_state = this.delegate.directory_state.as_ref()?;
|
||||
if directory_state.error.is_some() {
|
||||
this.delegate.matches.clear();
|
||||
|
@ -223,7 +223,7 @@ impl PickerDelegate for OpenPathDelegate {
|
|||
}
|
||||
|
||||
if suffix == "" {
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.update(cx, |this, cx| {
|
||||
this.delegate.matches.clear();
|
||||
this.delegate.string_matches.clear();
|
||||
this.delegate
|
||||
|
@ -250,7 +250,7 @@ impl PickerDelegate for OpenPathDelegate {
|
|||
return;
|
||||
}
|
||||
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.update(cx, |this, cx| {
|
||||
this.delegate.matches.clear();
|
||||
this.delegate.string_matches = matches.clone();
|
||||
this.delegate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue