History

`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

Michael Sloan committed 1 year ago

Commit b1872e31 parent f606b06120 files · +1146 −1267Browse files

Showing the changes to crates/buffer_diff/src/buffer_diff.rs (1 of 120 files). Show all

Unified · Split

crates/buffer_diff/src/buffer_diff.rs+5−7
@@ -1,6 +1,6 @@
11 use futures::{channel::oneshot, future::OptionFuture};
22 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};
44 use language::{Language, LanguageRegistry};
55 use rope::Rope;
66 use std::{cmp, future::Future, iter, ops::Range, sync::Arc};
@@ -615,11 +615,9 @@ impl BufferDiff { · 608 unmodified lines
615615 cx,
616616 )
617617 });
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));
621619
622− let hunks = cx.background_executor().spawn({
620+ let hunks = cx.background_spawn({
623621 let buffer = buffer.clone();
624622 async move { compute_hunks(diff_base, buffer) }
625623 });
@@ -641,7 +639,7 @@ impl BufferDiff { · 15 unmodified lines
641639 .clone()
642640 .map(|buffer| buffer.as_rope().clone()),
643641 );
644− cx.background_executor().spawn(async move {
642+ cx.background_spawn(async move {
645643 BufferDiffInner {
646644 hunks: compute_hunks(diff_base, buffer),
647645 base_text: diff_base_buffer,
@@ -998,7 +996,7 @@ mod tests { · 350 unmodified lines
998996 use std::fmt::Write as _;
999997
1000998 use super::*;
1001− use gpui::{AppContext as _, TestAppContext};
999+ use gpui::TestAppContext;
10021000 use rand::{rngs::StdRng, Rng as _};
10031001 use text::{Buffer, BufferId, Rope};
10041002 use unindent::Unindent as _;