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
Showing the changes to crates/buffer_diff/src/buffer_diff.rs (1 of 120 files). Show all
Unified · Split
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use futures::{channel::oneshot, future::OptionFuture}; |
| 2 | 2 | use git2::{DiffLineType as GitDiffLineType, DiffOptions as GitOptions, Patch as GitPatch}; |
| 3 | −use gpui::{App, AsyncApp, Context, Entity, EventEmitter}; | |
| 3 | +use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter}; | |
| 4 | 4 | use language::{Language, LanguageRegistry}; |
| 5 | 5 | use rope::Rope; |
| 6 | 6 | use std::{cmp, future::Future, iter, ops::Range, sync::Arc}; |
| @@ -615,11 +615,9 @@ impl BufferDiff { · 608 unmodified lines | ||
| 615 | 615 | cx, |
| 616 | 616 | ) |
| 617 | 617 | }); |
| 618 | − let base_text_snapshot = cx | |
| 619 | − .background_executor() | |
| 620 | − .spawn(OptionFuture::from(base_text_snapshot)); | |
| 618 | + let base_text_snapshot = cx.background_spawn(OptionFuture::from(base_text_snapshot)); | |
| 621 | 619 | |
| 622 | − let hunks = cx.background_executor().spawn({ | |
| 620 | + let hunks = cx.background_spawn({ | |
| 623 | 621 | let buffer = buffer.clone(); |
| 624 | 622 | async move { compute_hunks(diff_base, buffer) } |
| 625 | 623 | }); |
| @@ -641,7 +639,7 @@ impl BufferDiff { · 15 unmodified lines | ||
| 641 | 639 | .clone() |
| 642 | 640 | .map(|buffer| buffer.as_rope().clone()), |
| 643 | 641 | ); |
| 644 | − cx.background_executor().spawn(async move { | |
| 642 | + cx.background_spawn(async move { | |
| 645 | 643 | BufferDiffInner { |
| 646 | 644 | hunks: compute_hunks(diff_base, buffer), |
| 647 | 645 | base_text: diff_base_buffer, |
| @@ -998,7 +996,7 @@ mod tests { · 350 unmodified lines | ||
| 998 | 996 | use std::fmt::Write as _; |
| 999 | 997 | |
| 1000 | 998 | use super::*; |
| 1001 | − use gpui::{AppContext as _, TestAppContext}; | |
| 999 | + use gpui::TestAppContext; | |
| 1002 | 1000 | use rand::{rngs::StdRng, Rng as _}; |
| 1003 | 1001 | use text::{Buffer, BufferId, Rope}; |
| 1004 | 1002 | use unindent::Unindent as _; |