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
|
@ -412,13 +412,13 @@ impl InlayHintCache {
|
|||
} else {
|
||||
self.append_debounce
|
||||
};
|
||||
self.refresh_task = cx.spawn(|editor, mut cx| async move {
|
||||
self.refresh_task = cx.spawn(async move |editor, cx| {
|
||||
if let Some(debounce_duration) = debounce_duration {
|
||||
cx.background_executor().timer(debounce_duration).await;
|
||||
}
|
||||
|
||||
editor
|
||||
.update(&mut cx, |editor, cx| {
|
||||
.update(cx, |editor, cx| {
|
||||
spawn_new_update_tasks(
|
||||
editor,
|
||||
reason_description,
|
||||
|
@ -626,8 +626,8 @@ impl InlayHintCache {
|
|||
let server_id = *server_id;
|
||||
cached_hint.resolve_state = ResolveState::Resolving;
|
||||
drop(guard);
|
||||
cx.spawn_in(window, |editor, mut cx| async move {
|
||||
let resolved_hint_task = editor.update(&mut cx, |editor, cx| {
|
||||
cx.spawn_in(window, async move |editor, cx| {
|
||||
let resolved_hint_task = editor.update(cx, |editor, cx| {
|
||||
let buffer = editor.buffer().read(cx).buffer(buffer_id)?;
|
||||
editor.semantics_provider.as_ref()?.resolve_inlay_hint(
|
||||
hint_to_resolve,
|
||||
|
@ -639,7 +639,7 @@ impl InlayHintCache {
|
|||
if let Some(resolved_hint_task) = resolved_hint_task {
|
||||
let mut resolved_hint =
|
||||
resolved_hint_task.await.context("hint resolve task")?;
|
||||
editor.update(&mut cx, |editor, _| {
|
||||
editor.update(cx, |editor, _| {
|
||||
if let Some(excerpt_hints) =
|
||||
editor.inlay_hint_cache.hints.get(&excerpt_id)
|
||||
{
|
||||
|
@ -846,14 +846,14 @@ fn new_update_task(
|
|||
excerpt_buffer: Entity<Buffer>,
|
||||
cx: &mut Context<Editor>,
|
||||
) -> Task<()> {
|
||||
cx.spawn(move |editor, mut cx| async move {
|
||||
cx.spawn(async move |editor, cx| {
|
||||
let visible_range_update_results = future::join_all(
|
||||
query_ranges
|
||||
.visible
|
||||
.into_iter()
|
||||
.filter_map(|visible_range| {
|
||||
let fetch_task = editor
|
||||
.update(&mut cx, |_, cx| {
|
||||
.update(cx, |_, cx| {
|
||||
fetch_and_update_hints(
|
||||
excerpt_buffer.clone(),
|
||||
query,
|
||||
|
@ -891,7 +891,7 @@ fn new_update_task(
|
|||
|
||||
for (range, result) in visible_range_update_results {
|
||||
if let Err(e) = result {
|
||||
query_range_failed(&range, e, &mut cx);
|
||||
query_range_failed(&range, e, cx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -903,7 +903,7 @@ fn new_update_task(
|
|||
.chain(query_ranges.after_visible.into_iter())
|
||||
.filter_map(|invisible_range| {
|
||||
let fetch_task = editor
|
||||
.update(&mut cx, |_, cx| {
|
||||
.update(cx, |_, cx| {
|
||||
fetch_and_update_hints(
|
||||
excerpt_buffer.clone(),
|
||||
query,
|
||||
|
@ -919,7 +919,7 @@ fn new_update_task(
|
|||
.await;
|
||||
for (range, result) in invisible_range_update_results {
|
||||
if let Err(e) = result {
|
||||
query_range_failed(&range, e, &mut cx);
|
||||
query_range_failed(&range, e, cx);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -932,10 +932,10 @@ fn fetch_and_update_hints(
|
|||
invalidate: bool,
|
||||
cx: &mut Context<Editor>,
|
||||
) -> Task<anyhow::Result<()>> {
|
||||
cx.spawn(|editor, mut cx| async move {
|
||||
let buffer_snapshot = excerpt_buffer.update(&mut cx, |buffer, _| buffer.snapshot())?;
|
||||
cx.spawn(async move |editor, cx|{
|
||||
let buffer_snapshot = excerpt_buffer.update(cx, |buffer, _| buffer.snapshot())?;
|
||||
let (lsp_request_limiter, multi_buffer_snapshot) =
|
||||
editor.update(&mut cx, |editor, cx| {
|
||||
editor.update(cx, |editor, cx| {
|
||||
let multi_buffer_snapshot =
|
||||
editor.buffer().update(cx, |buffer, cx| buffer.snapshot(cx));
|
||||
let lsp_request_limiter = Arc::clone(&editor.inlay_hint_cache.lsp_request_limiter);
|
||||
|
@ -953,7 +953,7 @@ fn fetch_and_update_hints(
|
|||
let fetch_range_to_log = fetch_range.start.to_point(&buffer_snapshot)
|
||||
..fetch_range.end.to_point(&buffer_snapshot);
|
||||
let inlay_hints_fetch_task = editor
|
||||
.update(&mut cx, |editor, cx| {
|
||||
.update(cx, |editor, cx| {
|
||||
if got_throttled {
|
||||
let query_not_around_visible_range = match editor
|
||||
.excerpts_for_inlay_hints_query(None, cx)
|
||||
|
@ -997,7 +997,7 @@ fn fetch_and_update_hints(
|
|||
.ok()
|
||||
.flatten();
|
||||
|
||||
let cached_excerpt_hints = editor.update(&mut cx, |editor, _| {
|
||||
let cached_excerpt_hints = editor.update(cx, |editor, _| {
|
||||
editor
|
||||
.inlay_hint_cache
|
||||
.hints
|
||||
|
@ -1005,7 +1005,7 @@ fn fetch_and_update_hints(
|
|||
.cloned()
|
||||
})?;
|
||||
|
||||
let visible_hints = editor.update(&mut cx, |editor, cx| editor.visible_inlay_hints(cx))?;
|
||||
let visible_hints = editor.update(cx, |editor, cx| editor.visible_inlay_hints(cx))?;
|
||||
let new_hints = match inlay_hints_fetch_task {
|
||||
Some(fetch_task) => {
|
||||
log::debug!(
|
||||
|
@ -1050,7 +1050,7 @@ fn fetch_and_update_hints(
|
|||
);
|
||||
log::trace!("New update: {new_update:?}");
|
||||
editor
|
||||
.update(&mut cx, |editor, cx| {
|
||||
.update(cx, |editor, cx| {
|
||||
apply_hint_update(
|
||||
editor,
|
||||
new_update,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue