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
This commit is contained in:
Michael Sloan 2025-02-18 13:30:33 -07:00 committed by GitHub
parent f606b0641e
commit b1872e3afd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
120 changed files with 1146 additions and 1267 deletions

View file

@ -3012,7 +3012,7 @@ impl CodegenAlternative {
let executor = cx.background_executor().clone();
let message_id = message_id.clone();
let line_based_stream_diff: Task<anyhow::Result<()>> =
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let mut response_latency = None;
let request_start = Instant::now();
let diff = async {
@ -3326,8 +3326,7 @@ impl CodegenAlternative {
cx.spawn(|codegen, mut cx| async move {
let (deleted_row_ranges, inserted_row_ranges) = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
let old_text = old_snapshot
.text_for_range(
Point::new(old_range.start.row, 0)

View file

@ -1149,7 +1149,7 @@ impl Codegen {
let (mut hunks_tx, mut hunks_rx) = mpsc::channel(1);
let task = cx.background_executor().spawn({
let task = cx.background_spawn({
let message_id = message_id.clone();
let executor = cx.background_executor().clone();
async move {

View file

@ -493,7 +493,7 @@ impl CodegenAlternative {
let executor = cx.background_executor().clone();
let message_id = message_id.clone();
let line_based_stream_diff: Task<anyhow::Result<()>> =
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let mut response_latency = None;
let request_start = Instant::now();
let diff = async {
@ -807,8 +807,7 @@ impl CodegenAlternative {
cx.spawn(|codegen, mut cx| async move {
let (deleted_row_ranges, inserted_row_ranges) = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
let old_text = old_snapshot
.text_for_range(
Point::new(old_range.start.row, 0)

View file

@ -208,8 +208,7 @@ impl PickerDelegate for FetchContextPickerDelegate {
let confirm_behavior = self.confirm_behavior;
cx.spawn_in(window, |this, mut cx| async move {
let text = cx
.background_executor()
.spawn(Self::build_message(http_client, url.clone()))
.background_spawn(Self::build_message(http_client, url.clone()))
.await?;
this.update_in(&mut cx, |this, window, cx| {

View file

@ -123,7 +123,7 @@ impl PickerDelegate for ThreadContextPickerDelegate {
};
let executor = cx.background_executor().clone();
let search_task = cx.background_executor().spawn(async move {
let search_task = cx.background_spawn(async move {
if query.is_empty() {
threads
} else {

View file

@ -4,7 +4,7 @@ use std::sync::Arc;
use anyhow::{anyhow, bail, Result};
use collections::{BTreeMap, HashMap, HashSet};
use futures::{self, future, Future, FutureExt};
use gpui::{App, AsyncApp, Context, Entity, SharedString, Task, WeakEntity};
use gpui::{App, AppContext as _, AsyncApp, Context, Entity, SharedString, Task, WeakEntity};
use language::Buffer;
use project::{ProjectPath, Worktree};
use rope::Rope;
@ -456,9 +456,7 @@ fn collect_buffer_info_and_text(
};
// Important to collect version at the same time as content so that staleness logic is correct.
let content = buffer.as_rope().clone();
let text_task = cx
.background_executor()
.spawn(async move { to_fenced_codeblock(&path, content) });
let text_task = cx.background_spawn(async move { to_fenced_codeblock(&path, content) });
(buffer_info, text_task)
}

View file

@ -1,7 +1,7 @@
use crate::inline_prompt_editor::CodegenStatus;
use client::telemetry::Telemetry;
use futures::{channel::mpsc, SinkExt, StreamExt};
use gpui::{App, Context, Entity, EventEmitter, Task};
use gpui::{App, AppContext as _, Context, Entity, EventEmitter, Task};
use language_model::{LanguageModelRegistry, LanguageModelRequest};
use language_models::report_assistant_event;
use std::{sync::Arc, time::Instant};
@ -53,7 +53,7 @@ impl TerminalCodegen {
let (mut hunks_tx, mut hunks_rx) = mpsc::channel(1);
let task = cx.background_executor().spawn({
let task = cx.background_spawn({
let message_id = message_id.clone();
let executor = cx.background_executor().clone();
async move {

View file

@ -849,7 +849,7 @@ impl AssistantContext {
.collect::<Vec<_>>();
context_ops.extend(self.pending_ops.iter().cloned());
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let buffer_ops = buffer_ops.await;
context_ops.sort_unstable_by_key(|op| op.timestamp());
buffer_ops

View file

@ -265,8 +265,7 @@ impl ContextStore {
local_versions.push(context.version(cx).to_proto(context_id.clone()));
let client = this.client.clone();
let project_id = envelope.payload.project_id;
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let operations = operations.await;
for operation in operations {
client.send(proto::UpdateContext {
@ -401,8 +400,7 @@ impl ContextStore {
)
})?;
let operations = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
context_proto
.operations
.into_iter()
@ -436,7 +434,7 @@ impl ContextStore {
let languages = self.languages.clone();
let project = self.project.clone();
let telemetry = self.telemetry.clone();
let load = cx.background_executor().spawn({
let load = cx.background_spawn({
let path = path.clone();
async move {
let saved_context = fs.load(&path).await?;
@ -539,8 +537,7 @@ impl ContextStore {
)
})?;
let operations = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
context_proto
.operations
.into_iter()
@ -693,7 +690,7 @@ impl ContextStore {
pub fn search(&self, query: String, cx: &App) -> Task<Vec<SavedContextMetadata>> {
let metadata = self.contexts_metadata.clone();
let executor = cx.background_executor().clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
if query.is_empty() {
metadata
} else {

View file

@ -2,7 +2,7 @@ use anyhow::{anyhow, Context as _, Result};
use collections::HashMap;
use editor::ProposedChangesEditor;
use futures::{future, TryFutureExt as _};
use gpui::{App, AsyncApp, Entity, SharedString};
use gpui::{App, AppContext as _, AsyncApp, Entity, SharedString};
use language::{AutoindentMode, Buffer, BufferSnapshot};
use project::{Project, ProjectPath};
use std::{cmp, ops::Range, path::Path, sync::Arc};
@ -258,8 +258,7 @@ impl AssistantEdit {
let snapshot = buffer.update(&mut cx, |buffer, _| buffer.snapshot())?;
let suggestion = cx
.background_executor()
.spawn(async move { kind.resolve(&snapshot) })
.background_spawn(async move { kind.resolve(&snapshot) })
.await;
Ok((buffer, suggestion))
@ -547,7 +546,7 @@ impl Eq for AssistantPatch {}
#[cfg(test)]
mod tests {
use super::*;
use gpui::{App, AppContext as _};
use gpui::App;
use language::{
language_settings::AllLanguageSettings, Language, LanguageConfig, LanguageMatcher,
};

View file

@ -4,7 +4,7 @@ pub use assistant_slash_command::SlashCommand;
use assistant_slash_command::{AfterCompletion, SlashCommandLine, SlashCommandWorkingSet};
use editor::{CompletionProvider, Editor};
use fuzzy::{match_strings, StringMatchCandidate};
use gpui::{App, Context, Entity, Task, WeakEntity, Window};
use gpui::{App, AppContext as _, Context, Entity, Task, WeakEntity, Window};
use language::{Anchor, Buffer, CompletionDocumentation, LanguageServerId, ToPoint};
use parking_lot::Mutex;
use project::CompletionIntent;
@ -162,7 +162,7 @@ impl SlashCommandCompletionProvider {
let editor = self.editor.clone();
let workspace = self.workspace.clone();
let arguments = arguments.to_vec();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
Ok(completions
.await?
.into_iter()

View file

@ -102,8 +102,7 @@ impl PickerDelegate for SlashCommandDelegate {
let all_commands = self.all_commands.clone();
cx.spawn_in(window, |this, mut cx| async move {
let filtered_commands = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
if query.is_empty() {
all_commands
} else {

View file

@ -103,7 +103,7 @@ impl SlashCommand for ExtensionSlashCommand {
) -> Task<Result<Vec<ArgumentCompletion>>> {
let command = self.command.clone();
let arguments = arguments.to_owned();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let completions = self
.extension
.complete_slash_command_argument(command, arguments)
@ -135,7 +135,7 @@ impl SlashCommand for ExtensionSlashCommand {
) -> Task<SlashCommandResult> {
let command = self.command.clone();
let arguments = arguments.to_owned();
let output = cx.background_executor().spawn(async move {
let output = cx.background_spawn(async move {
let delegate =
delegate.map(|delegate| Arc::new(WorktreeDelegateAdapter(delegate.clone())) as _);
let output = self

View file

@ -82,7 +82,7 @@ impl SlashCommand for AutoCommand {
project_index.flush_summary_backlogs(cx)
})?;
cx.background_executor().spawn(task).await;
cx.background_spawn(task).await;
anyhow::Ok(Vec::new())
})
@ -129,7 +129,7 @@ impl SlashCommand for AutoCommand {
// so you don't have to write it again.
let original_prompt = argument.to_string();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let commands = task.await?;
let mut prompt = String::new();
@ -285,8 +285,7 @@ async fn commands_for_summaries(
})
.collect::<Vec<_>>();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let futures = completion_streams
.into_iter()
.enumerate()

View file

@ -132,7 +132,7 @@ impl SlashCommand for CargoWorkspaceSlashCommand {
let project = workspace.project().clone();
let fs = workspace.project().read(cx).fs().clone();
let path = Self::path_to_cargo_toml(project, cx);
let output = cx.background_executor().spawn(async move {
let output = cx.background_spawn(async move {
let path = path.with_context(|| "Cargo.toml not found")?;
Self::build_message(fs, &path).await
});

View file

@ -54,7 +54,7 @@ impl SlashCommand for DefaultSlashCommand {
cx: &mut App,
) -> Task<SlashCommandResult> {
let store = PromptStore::global(cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let store = store.await?;
let prompts = store.default_prompt_metadata();

View file

@ -86,7 +86,7 @@ impl SlashCommand for DeltaSlashCommand {
}
}
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let mut output = SlashCommandOutput::default();
let mut changes_detected = false;

View file

@ -129,7 +129,7 @@ impl SlashCommand for DiagnosticsSlashCommand {
let paths = self.search_paths(query.clone(), cancellation_flag.clone(), &workspace, cx);
let executor = cx.background_executor().clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let mut matches: Vec<String> = paths
.await
.into_iter()

View file

@ -176,7 +176,7 @@ impl SlashCommand for DocsSlashCommand {
.provider()
.ok_or_else(|| anyhow!("no docs provider specified"))
.and_then(|provider| IndexedDocsStore::try_global(provider, cx));
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
fn build_completions(items: Vec<String>) -> Vec<ArgumentCompletion> {
items
.into_iter()
@ -284,7 +284,7 @@ impl SlashCommand for DocsSlashCommand {
let args = DocsSlashCommandArgs::parse(arguments);
let executor = cx.background_executor().clone();
let task = cx.background_executor().spawn({
let task = cx.background_spawn({
let store = args
.provider()
.ok_or_else(|| anyhow!("no docs provider specified"))

View file

@ -151,7 +151,7 @@ impl SlashCommand for FetchSlashCommand {
let http_client = workspace.read(cx).client().http_client();
let url = argument.to_string();
let text = cx.background_executor().spawn({
let text = cx.background_spawn({
let url = url.clone();
async move { Self::build_message(http_client, &url).await }
});

View file

@ -156,7 +156,7 @@ impl SlashCommand for FileSlashCommand {
cx,
);
let comment_id = cx.theme().syntax().highlight_id("comment").map(HighlightId);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
Ok(paths
.await
.into_iter()

View file

@ -130,8 +130,7 @@ impl SlashCommand for ProjectSlashCommand {
let results = SemanticDb::load_results(results, &fs, &cx).await?;
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let mut output = "Project context:\n".to_string();
let mut sections = Vec::new();

View file

@ -43,7 +43,7 @@ impl SlashCommand for PromptSlashCommand {
) -> Task<Result<Vec<ArgumentCompletion>>> {
let store = PromptStore::global(cx);
let query = arguments.to_owned().join(" ");
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let prompts = store.await?.search(query).await;
Ok(prompts
.into_iter()
@ -77,7 +77,7 @@ impl SlashCommand for PromptSlashCommand {
let store = PromptStore::global(cx);
let title = SharedString::from(title.clone());
let prompt = cx.background_executor().spawn({
let prompt = cx.background_spawn({
let title = title.clone();
async move {
let store = store.await?;

View file

@ -119,8 +119,7 @@ impl SlashCommand for SearchSlashCommand {
let loaded_results = SemanticDb::load_results(results, &fs, &cx).await?;
let output = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
let mut text = format!("Search results for {query}:\n");
let mut sections = Vec::new();
for loaded_result in &loaded_results {

View file

@ -63,8 +63,7 @@ impl SlashCommand for StreamingExampleSlashCommand {
cx: &mut App,
) -> Task<SlashCommandResult> {
let (events_tx, events_rx) = mpsc::unbounded();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
events_tx.unbounded_send(Ok(SlashCommandEvent::StartSection {
icon: IconName::FileRust,
label: "Section 1".into(),

View file

@ -4,7 +4,7 @@ use assistant_slash_command::{
SlashCommandResult,
};
use editor::Editor;
use gpui::{Task, WeakEntity};
use gpui::{AppContext as _, Task, WeakEntity};
use language::{BufferSnapshot, LspAdapterDelegate};
use std::sync::Arc;
use std::{path::Path, sync::atomic::AtomicBool};
@ -69,7 +69,7 @@ impl SlashCommand for OutlineSlashCommand {
let snapshot = buffer.read(cx).snapshot();
let path = snapshot.resolve_file_path(cx, true);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let outline = snapshot
.outline(None)
.context("no symbols for active tab")?;

View file

@ -152,7 +152,7 @@ impl SlashCommand for TabSlashCommand {
cx,
);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let mut output = SlashCommandOutput::default();
for (full_path, buffer, _) in tab_items_search.await? {
append_buffer_to_output(&buffer, full_path.as_deref(), &mut output).log_err();
@ -212,8 +212,7 @@ fn tab_items_for_queries(
})??;
let background_executor = cx.background_executor().clone();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
open_buffers.sort_by_key(|(_, _, timestamp)| *timestamp);
if empty_query
|| queries

View file

@ -513,7 +513,7 @@ impl AutoUpdater {
should_show: bool,
cx: &App,
) -> Task<Result<()>> {
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
if should_show {
KEY_VALUE_STORE
.write_kvp(
@ -531,7 +531,7 @@ impl AutoUpdater {
}
pub fn should_show_update_notification(&self, cx: &App) -> Task<Result<bool>> {
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
Ok(KEY_VALUE_STORE
.read_kvp(SHOULD_SHOW_UPDATE_NOTIFICATION_KEY)?
.is_some())

View file

@ -1,6 +1,6 @@
use futures::{channel::oneshot, future::OptionFuture};
use git2::{DiffLineType as GitDiffLineType, DiffOptions as GitOptions, Patch as GitPatch};
use gpui::{App, AsyncApp, Context, Entity, EventEmitter};
use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter};
use language::{Language, LanguageRegistry};
use rope::Rope;
use std::{cmp, future::Future, iter, ops::Range, sync::Arc};
@ -615,11 +615,9 @@ impl BufferDiff {
cx,
)
});
let base_text_snapshot = cx
.background_executor()
.spawn(OptionFuture::from(base_text_snapshot));
let base_text_snapshot = cx.background_spawn(OptionFuture::from(base_text_snapshot));
let hunks = cx.background_executor().spawn({
let hunks = cx.background_spawn({
let buffer = buffer.clone();
async move { compute_hunks(diff_base, buffer) }
});
@ -641,7 +639,7 @@ impl BufferDiff {
.clone()
.map(|buffer| buffer.as_rope().clone()),
);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
BufferDiffInner {
hunks: compute_hunks(diff_base, buffer),
base_text: diff_base_buffer,
@ -998,7 +996,7 @@ mod tests {
use std::fmt::Write as _;
use super::*;
use gpui::{AppContext as _, TestAppContext};
use gpui::TestAppContext;
use rand::{rngs::StdRng, Rng as _};
use text::{Buffer, BufferId, Rope};
use unindent::Unindent as _;

View file

@ -241,7 +241,7 @@ impl ActiveCall {
})
.shared();
self.pending_room_creation = Some(room.clone());
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
room.await.map_err(|err| anyhow!("{:?}", err))?;
anyhow::Ok(())
})
@ -278,7 +278,7 @@ impl ActiveCall {
};
let client = self.client.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
client
.request(proto::CancelCall {
room_id,

View file

@ -13,7 +13,7 @@ use client::{
use collections::{BTreeMap, HashMap, HashSet};
use fs::Fs;
use futures::{FutureExt, StreamExt};
use gpui::{App, AppContext, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity};
use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity};
use language::LanguageRegistry;
#[cfg(not(all(target_os = "windows", target_env = "gnu")))]
use livekit::{
@ -255,7 +255,7 @@ impl Room {
fn app_will_quit(&mut self, cx: &mut Context<Self>) -> impl Future<Output = ()> {
let task = if self.status.is_online() {
let leave = self.leave_internal(cx);
Some(cx.background_executor().spawn(async move {
Some(cx.background_spawn(async move {
leave.await.log_err();
}))
} else {
@ -322,7 +322,7 @@ impl Room {
self.clear_state(cx);
let leave_room = self.client.request(proto::LeaveRoom {});
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
leave_room.await?;
anyhow::Ok(())
})
@ -1248,7 +1248,7 @@ impl Room {
};
cx.notify();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
client
.request(proto::UpdateParticipantLocation {
room_id,
@ -1373,8 +1373,7 @@ impl Room {
match publication {
Ok(publication) => {
if canceled {
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
participant.unpublish_track(&publication.sid()).await
})
.detach_and_log_err(cx)
@ -1465,8 +1464,7 @@ impl Room {
match publication {
Ok(publication) => {
if canceled {
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
participant.unpublish_track(&publication.sid()).await
})
.detach()
@ -1561,8 +1559,9 @@ impl Room {
{
let local_participant = live_kit.room.local_participant();
let sid = track_publication.sid();
cx.background_executor()
.spawn(async move { local_participant.unpublish_track(&sid).await })
cx.background_spawn(
async move { local_participant.unpublish_track(&sid).await },
)
.detach_and_log_err(cx);
cx.notify();
}
@ -1722,8 +1721,7 @@ impl LiveKitRoom {
}
let participant = self.room.local_participant();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
for sid in tracks_to_unpublish {
participant.unpublish_track(&sid).await.log_err();
}

View file

@ -234,7 +234,7 @@ impl ActiveCall {
})
.shared();
self.pending_room_creation = Some(room.clone());
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
room.await.map_err(|err| anyhow!("{:?}", err))?;
anyhow::Ok(())
})
@ -271,7 +271,7 @@ impl ActiveCall {
};
let client = self.client.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
client
.request(proto::CancelCall {
room_id,

View file

@ -311,7 +311,7 @@ impl Room {
fn app_will_quit(&mut self, cx: &mut Context<Self>) -> impl Future<Output = ()> {
let task = if self.status.is_online() {
let leave = self.leave_internal(cx);
Some(cx.background_executor().spawn(async move {
Some(cx.background_spawn(async move {
leave.await.log_err();
}))
} else {
@ -378,7 +378,7 @@ impl Room {
self.clear_state(cx);
let leave_room = self.client.request(proto::LeaveRoom {});
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
leave_room.await?;
anyhow::Ok(())
})
@ -1268,7 +1268,7 @@ impl Room {
};
cx.notify();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
client
.request(proto::UpdateParticipantLocation {
room_id,
@ -1385,9 +1385,7 @@ impl Room {
live_kit.room.unpublish_track(publication);
} else {
if live_kit.muted_by_user || live_kit.deafened {
cx.background_executor()
.spawn(publication.set_mute(true))
.detach();
cx.background_spawn(publication.set_mute(true)).detach();
}
live_kit.microphone_track = LocalTrack::Published {
track_publication: publication,

View file

@ -514,8 +514,7 @@ impl ChannelStore {
}
}
};
cx.background_executor()
.spawn(async move { task.await.map_err(|error| anyhow!("{}", error)) })
cx.background_spawn(async move { task.await.map_err(|error| anyhow!("{}", error)) })
}
pub fn is_channel_admin(&self, channel_id: ChannelId) -> bool {
@ -781,7 +780,7 @@ impl ChannelStore {
cx: &mut Context<Self>,
) -> Task<Result<()>> {
let client = self.client.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
client
.request(proto::RespondToChannelInvite {
channel_id: channel_id.0,
@ -975,12 +974,9 @@ impl ChannelStore {
if let Some(operations) = operations {
let client = this.client.clone();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let operations = operations.await;
for chunk in
language::proto::split_operations(operations)
{
for chunk in language::proto::split_operations(operations) {
client
.send(proto::UpdateChannelBuffer {
channel_id: channel_id.0,

View file

@ -19,7 +19,7 @@ use futures::{
channel::oneshot, future::BoxFuture, AsyncReadExt, FutureExt, SinkExt, Stream, StreamExt,
TryFutureExt as _, TryStreamExt,
};
use gpui::{actions, App, AsyncApp, Entity, Global, Task, WeakEntity};
use gpui::{actions, App, AppContext as _, AsyncApp, Entity, Global, Task, WeakEntity};
use http_client::{AsyncBody, HttpClient, HttpClientWithUrl};
use parking_lot::RwLock;
use postage::watch;
@ -1064,7 +1064,7 @@ impl Client {
let rpc_url = self.rpc_url(http, release_channel);
let system_id = self.telemetry.system_id();
let metrics_id = self.telemetry.metrics_id();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
use HttpOrHttps::*;
#[derive(Debug)]
@ -1743,7 +1743,7 @@ mod tests {
use crate::test::FakeServer;
use clock::FakeSystemClock;
use gpui::{AppContext as _, BackgroundExecutor, TestAppContext};
use gpui::{BackgroundExecutor, TestAppContext};
use http_client::FakeHttpClient;
use parking_lot::Mutex;
use proto::TypedEnvelope;
@ -1806,7 +1806,7 @@ mod tests {
// Time out when client tries to connect.
client.override_authenticate(move |cx| {
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
Ok(Credentials {
user_id,
access_token: "token".into(),
@ -1814,7 +1814,7 @@ mod tests {
})
});
client.override_establish_connection(|_, cx| {
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
future::pending::<()>().await;
unreachable!()
})
@ -1848,7 +1848,7 @@ mod tests {
// Time out when re-establishing the connection.
server.allow_connections();
client.override_establish_connection(|_, cx| {
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
future::pending::<()>().await;
unreachable!()
})
@ -1887,7 +1887,7 @@ mod tests {
move |cx| {
let auth_count = auth_count.clone();
let dropped_auth_count = dropped_auth_count.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
*auth_count.lock() += 1;
let _drop = util::defer(move || *dropped_auth_count.lock() += 1);
future::pending::<()>().await;

View file

@ -5,7 +5,7 @@ use anyhow::Result;
use clock::SystemClock;
use futures::channel::mpsc;
use futures::{Future, StreamExt};
use gpui::{App, BackgroundExecutor, Task};
use gpui::{App, AppContext as _, BackgroundExecutor, Task};
use http_client::{self, AsyncBody, HttpClient, HttpClientWithUrl, Method, Request};
use parking_lot::Mutex;
use release_channel::ReleaseChannel;
@ -219,8 +219,7 @@ impl Telemetry {
}));
Self::log_file_path();
cx.background_executor()
.spawn({
cx.background_spawn({
let state = state.clone();
let os_version = os_version();
state.lock().os_version = Some(os_version.clone());
@ -252,8 +251,7 @@ impl Telemetry {
let (tx, mut rx) = mpsc::unbounded();
::telemetry::init(tx);
cx.background_executor()
.spawn({
cx.background_spawn({
let this = Arc::downgrade(&this);
async move {
while let Some(event) = rx.next().await {

View file

@ -85,7 +85,7 @@ impl FakeServer {
Connection::in_memory(cx.background_executor().clone());
let (connection_id, io, incoming) =
peer.add_test_connection(server_conn, cx.background_executor().clone());
cx.background_executor().spawn(io).detach();
cx.background_spawn(io).detach();
{
let mut state = state.lock();
state.connection_id = Some(connection_id);

View file

@ -244,8 +244,7 @@ impl TestServer {
.await
.expect("retrieving user failed")
.unwrap();
cx.background_executor()
.spawn(server.handle_connection(
cx.background_spawn(server.handle_connection(
server_conn,
client_name,
Principal::User(user),

View file

@ -201,8 +201,7 @@ impl ChatPanel {
) -> Task<Result<Entity<Self>>> {
cx.spawn(|mut cx| async move {
let serialized_panel = if let Some(panel) = cx
.background_executor()
.spawn(async move { KEY_VALUE_STORE.read_kvp(CHAT_PANEL_KEY) })
.background_spawn(async move { KEY_VALUE_STORE.read_kvp(CHAT_PANEL_KEY) })
.await
.log_err()
.flatten()
@ -227,7 +226,7 @@ impl ChatPanel {
fn serialize(&mut self, cx: &mut Context<Self>) {
let width = self.width;
self.pending_serialization = cx.background_executor().spawn(
self.pending_serialization = cx.background_spawn(
async move {
KEY_VALUE_STORE
.write_kvp(

View file

@ -454,8 +454,7 @@ impl MessageEditor {
mut cx: AsyncWindowContext,
) {
let (buffer, ranges) = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
let ranges = MENTIONS_SEARCH.search(&buffer, None).await;
(buffer, ranges)
})

View file

@ -319,8 +319,7 @@ impl CollabPanel {
mut cx: AsyncWindowContext,
) -> anyhow::Result<Entity<Self>> {
let serialized_panel = cx
.background_executor()
.spawn(async move { KEY_VALUE_STORE.read_kvp(COLLABORATION_PANEL_KEY) })
.background_spawn(async move { KEY_VALUE_STORE.read_kvp(COLLABORATION_PANEL_KEY) })
.await
.map_err(|_| anyhow::anyhow!("Failed to read collaboration panel from key value store"))
.log_err()
@ -351,7 +350,7 @@ impl CollabPanel {
fn serialize(&mut self, cx: &mut Context<Self>) {
let width = self.width;
let collapsed_channels = self.collapsed_channels.clone();
self.pending_serialization = cx.background_executor().spawn(
self.pending_serialization = cx.background_spawn(
async move {
KEY_VALUE_STORE
.write_kvp(

View file

@ -183,8 +183,7 @@ impl NotificationPanel {
) -> Task<Result<Entity<Self>>> {
cx.spawn(|mut cx| async move {
let serialized_panel = if let Some(panel) = cx
.background_executor()
.spawn(async move { KEY_VALUE_STORE.read_kvp(NOTIFICATION_PANEL_KEY) })
.background_spawn(async move { KEY_VALUE_STORE.read_kvp(NOTIFICATION_PANEL_KEY) })
.await
.log_err()
.flatten()
@ -209,7 +208,7 @@ impl NotificationPanel {
fn serialize(&mut self, cx: &mut Context<Self>) {
let width = self.width;
self.pending_serialization = cx.background_executor().spawn(
self.pending_serialization = cx.background_spawn(
async move {
KEY_VALUE_STORE
.write_kvp(

View file

@ -281,7 +281,7 @@ impl PickerDelegate for CommandPaletteDelegate {
query = alias.to_string();
}
let (mut tx, mut rx) = postage::dispatch::channel(1);
let task = cx.background_executor().spawn({
let task = cx.background_spawn({
let mut commands = self.all_commands.clone();
let hit_counts = cx.global::<HitCounts>().clone();
let executor = cx.background_executor().clone();

View file

@ -1,7 +1,7 @@
use anyhow::{anyhow, Context as _, Result};
use collections::HashMap;
use futures::{channel::oneshot, io::BufWriter, select, AsyncRead, AsyncWrite, FutureExt};
use gpui::{AsyncApp, BackgroundExecutor, Task};
use gpui::{AppContext as _, AsyncApp, BackgroundExecutor, Task};
use parking_lot::Mutex;
use postage::barrier;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
@ -192,7 +192,7 @@ impl Client {
let (stdout, stderr) = futures::join!(stdout_input_task, stderr_input_task);
stdout.or(stderr)
});
let output_task = cx.background_executor().spawn({
let output_task = cx.background_spawn({
Self::handle_output(
stdin,
outbound_rx,

View file

@ -234,8 +234,7 @@ impl RegisteredBuffer {
let new_snapshot = buffer.update(&mut cx, |buffer, _| buffer.snapshot()).ok()?;
let content_changes = cx
.background_executor()
.spawn({
.background_spawn({
let new_snapshot = new_snapshot.clone();
async move {
new_snapshot
@ -588,8 +587,7 @@ impl Copilot {
}
};
cx.background_executor()
.spawn(task.map_err(|err| anyhow!("{:?}", err)))
cx.background_spawn(task.map_err(|err| anyhow!("{:?}", err)))
} else {
// If we're downloading, wait until download is finished
// If we're in a stuck state, display to the user
@ -601,7 +599,7 @@ impl Copilot {
self.update_sign_in_status(request::SignInStatus::NotSignedIn, cx);
if let CopilotServer::Running(RunningCopilotServer { lsp: server, .. }) = &self.server {
let server = server.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
server
.request::<request::SignOut>(request::SignOutParams {})
.await?;
@ -631,7 +629,7 @@ impl Copilot {
cx.notify();
cx.background_executor().spawn(start_task)
cx.background_spawn(start_task)
}
pub fn language_server(&self) -> Option<&Arc<LanguageServer>> {
@ -813,7 +811,7 @@ impl Copilot {
.request::<request::NotifyAccepted>(request::NotifyAcceptedParams {
uuid: completion.uuid.clone(),
});
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
request.await?;
Ok(())
})
@ -837,7 +835,7 @@ impl Copilot {
.map(|completion| completion.uuid.clone())
.collect(),
});
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
request.await?;
Ok(())
})
@ -884,7 +882,7 @@ impl Copilot {
.map(|file| file.path().to_path_buf())
.unwrap_or_default();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let (version, snapshot) = snapshot.await?;
let result = lsp
.request::<R>(request::GetCompletionsParams {

View file

@ -4,7 +4,7 @@ pub mod query;
// Re-export
pub use anyhow;
use anyhow::Context as _;
use gpui::App;
use gpui::{App, AppContext};
pub use indoc::indoc;
pub use paths::database_dir;
pub use smol;
@ -192,8 +192,7 @@ pub fn write_and_log<F>(cx: &App, db_write: impl FnOnce() -> F + Send + 'static)
where
F: Future<Output = anyhow::Result<()>> + Send,
{
cx.background_executor()
.spawn(async move { db_write().await.log_err() })
cx.background_spawn(async move { db_write().await.log_err() })
.detach()
}

View file

@ -171,7 +171,7 @@ impl WrapMap {
let text_system = cx.text_system().clone();
let (font, font_size) = self.font_with_size.clone();
let task = cx.background_executor().spawn(async move {
let task = cx.background_spawn(async move {
let mut line_wrapper = text_system.line_wrapper(font, font_size);
let tab_snapshot = new_snapshot.tab_snapshot.clone();
let range = TabPoint::zero()..tab_snapshot.max_point();
@ -255,7 +255,7 @@ impl WrapMap {
let mut snapshot = self.snapshot.clone();
let text_system = cx.text_system().clone();
let (font, font_size) = self.font_with_size.clone();
let update_task = cx.background_executor().spawn(async move {
let update_task = cx.background_spawn(async move {
let mut edits = Patch::default();
let mut line_wrapper = text_system.line_wrapper(font, font_size);
for (tab_snapshot, tab_edits) in pending_edits {

View file

@ -4798,7 +4798,7 @@ impl Editor {
let Some(matches_task) = editor
.read_with(&mut cx, |editor, cx| {
let buffer = editor.buffer().read(cx).snapshot(cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let mut ranges = Vec::new();
let buffer_ranges =
vec![buffer.anchor_before(0)..buffer.anchor_after(buffer.len())];
@ -10221,8 +10221,7 @@ impl Editor {
return;
}
let new_rows =
cx.background_executor()
.spawn({
cx.background_spawn({
let snapshot = display_snapshot.clone();
async move {
Self::fetch_runnable_ranges(&snapshot, Anchor::min()..Anchor::max())
@ -10989,7 +10988,7 @@ impl Editor {
HoverLink::InlayHint(lsp_location, server_id) => {
let computation =
self.compute_target_location(lsp_location, server_id, window, cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let location = computation.await?;
Ok(TargetTaskResult::Location(location))
})
@ -15587,7 +15586,7 @@ fn snippet_completions(
let scope = language.map(|language| language.default_scope());
let executor = cx.background_executor().clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let classifier = CharClassifier::new(scope).for_completion(true);
let mut last_word = chars
.chars()
@ -15717,7 +15716,7 @@ impl CompletionProvider for Entity<Project> {
self.update(cx, |project, cx| {
let snippets = snippet_completions(project, buffer, buffer_position, cx);
let project_completions = project.completions(buffer, buffer_position, options, cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let mut completions = project_completions.await?;
let snippets_completions = snippets.await?;
completions.extend(snippets_completions);

View file

@ -5264,8 +5264,7 @@ impl EditorElement {
Some(cx.spawn_in(window, |editor, mut cx| async move {
let scrollbar_size = scrollbar_layout.hitbox.size;
let scrollbar_markers = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
let max_point = snapshot.display_snapshot.buffer_snapshot.max_point();
let mut marker_quads = Vec::new();
if scrollbar_settings.git_diff {

View file

@ -4,7 +4,7 @@ use git::{
blame::{Blame, BlameEntry},
parse_git_remote_url, GitHostingProvider, GitHostingProviderRegistry, Oid,
};
use gpui::{App, Context, Entity, Subscription, Task};
use gpui::{App, AppContext as _, Context, Entity, Subscription, Task};
use http_client::HttpClient;
use language::{markdown, Bias, Buffer, BufferSnapshot, Edit, LanguageRegistry, ParsedMarkdown};
use multi_buffer::RowInfo;
@ -360,8 +360,7 @@ impl GitBlame {
self.task = cx.spawn(|this, mut cx| async move {
let result = cx
.background_executor()
.spawn({
.background_spawn({
let snapshot = snapshot.clone();
async move {
let Some(Blame {
@ -549,7 +548,7 @@ async fn parse_markdown(text: &str, language_registry: &Arc<LanguageRegistry>) -
#[cfg(test)]
mod tests {
use super::*;
use gpui::{AppContext as _, Context};
use gpui::Context;
use language::{Point, Rope};
use project::FakeFs;
use rand::prelude::*;

View file

@ -1,7 +1,7 @@
use collections::{HashMap, HashSet};
use git::diff::DiffHunkStatus;
use gpui::{
Action, AppContext, Corner, CursorStyle, Focusable as _, Hsla, Model, MouseButton,
Action, AppContext as _, Corner, CursorStyle, Focusable as _, Hsla, Model, MouseButton,
Subscription, Task,
};
use language::{Buffer, BufferId, Point};
@ -372,7 +372,7 @@ impl Editor {
self.diff_map
.hunk_update_tasks
.insert(None, cx.background_executor().spawn(new_toggle_task));
.insert(None, cx.background_spawn(new_toggle_task));
}
pub(super) fn expand_diff_hunk(
@ -1089,10 +1089,9 @@ impl Editor {
.ok();
});
diff_map.hunk_update_tasks.insert(
Some(buffer_id),
cx.background_executor().spawn(new_sync_task),
);
diff_map
.hunk_update_tasks
.insert(Some(buffer_id), cx.background_spawn(new_sync_task));
}
fn go_to_subsequent_hunk(

View file

@ -1,7 +1,7 @@
use std::{ops::Range, time::Duration};
use collections::HashSet;
use gpui::{App, Context, Task, Window};
use gpui::{App, AppContext as _, Context, Task, Window};
use language::language_settings::language_settings;
use multi_buffer::{IndentGuide, MultiBufferRow};
use text::{LineIndent, Point};
@ -102,9 +102,7 @@ impl Editor {
let snapshot = snapshot.clone();
let task = cx
.background_executor()
.spawn(resolve_indented_range(snapshot, cursor_row));
let task = cx.background_spawn(resolve_indented_range(snapshot, cursor_row));
// Try to resolve the indent in a short amount of time, otherwise move it to a background task.
match cx
@ -115,7 +113,7 @@ impl Editor {
Err(future) => {
state.pending_refresh =
Some(cx.spawn_in(window, |editor, mut cx| async move {
let result = cx.background_executor().spawn(future).await;
let result = cx.background_spawn(future).await;
editor
.update(&mut cx, |editor, _| {
editor.active_indent_guides_state.active_indent_range = result;

View file

@ -19,7 +19,7 @@ use crate::{
use anyhow::Context as _;
use clock::Global;
use futures::future;
use gpui::{AsyncApp, Context, Entity, Task, Window};
use gpui::{AppContext as _, AsyncApp, Context, Entity, Task, Window};
use language::{language_settings::InlayHintKind, Buffer, BufferSnapshot};
use parking_lot::RwLock;
use project::{InlayHint, ResolveState};
@ -996,9 +996,7 @@ fn fetch_and_update_hints(
let background_task_buffer_snapshot = buffer_snapshot.clone();
let background_fetch_range = fetch_range.clone();
let new_update = cx
.background_executor()
.spawn(async move {
let new_update = cx.background_spawn(async move {
calculate_hint_updates(
query.excerpt_id,
invalidate,

View file

@ -1225,8 +1225,7 @@ impl SerializableItem for Editor {
let snapshot = buffer.read(cx).snapshot();
Some(cx.spawn_in(window, |_this, cx| async move {
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let (contents, language) = if serialize_dirty_buffers && is_dirty {
let contents = snapshot.text();
let language = snapshot.language().map(|lang| lang.name().to_string());
@ -1540,7 +1539,7 @@ impl SearchableItem for Editor {
ranges.iter().cloned().collect::<Vec<_>>()
});
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let mut ranges = Vec::new();
let search_within_ranges = if search_within_ranges.is_empty() {

View file

@ -1,6 +1,6 @@
use crate::Editor;
use gpui::{App, Task as AsyncTask, Window};
use gpui::{App, AppContext as _, Task as AsyncTask, Window};
use project::Location;
use task::{TaskContext, TaskVariables, VariableName};
use text::{ToOffset, ToPoint};
@ -88,7 +88,6 @@ pub fn task_context(
};
editor.update(cx, |editor, cx| {
let context_task = task_context_with_editor(editor, window, cx);
cx.background_executor()
.spawn(async move { context_task.await.unwrap_or_default() })
cx.background_spawn(async move { context_task.await.unwrap_or_default() })
})
}

View file

@ -324,10 +324,7 @@ impl ExtensionStore {
load_initial_extensions.await;
let mut index_changed = false;
let mut debounce_timer = cx
.background_executor()
.spawn(futures::future::pending())
.fuse();
let mut debounce_timer = cx.background_spawn(futures::future::pending()).fuse();
loop {
select_biased! {
_ = debounce_timer => {
@ -370,7 +367,7 @@ impl ExtensionStore {
// Watch the installed extensions directory for changes. Whenever changes are
// detected, rebuild the extension index, and load/unload any extensions that
// have been added, removed, or modified.
this.tasks.push(cx.background_executor().spawn({
this.tasks.push(cx.background_spawn({
let fs = this.fs.clone();
let reload_tx = this.reload_tx.clone();
let installed_dir = this.installed_dir.clone();
@ -886,8 +883,7 @@ impl ExtensionStore {
}
});
cx.background_executor()
.spawn({
cx.background_spawn({
let extension_source_path = extension_source_path.clone();
async move {
builder
@ -937,7 +933,7 @@ impl ExtensionStore {
};
cx.notify();
let compile = cx.background_executor().spawn(async move {
let compile = cx.background_spawn(async move {
let mut manifest = ExtensionManifest::load(fs, &path).await?;
builder
.compile_extension(
@ -1192,8 +1188,7 @@ impl ExtensionStore {
cx.emit(Event::ExtensionsUpdated);
cx.spawn(|this, mut cx| async move {
cx.background_executor()
.spawn({
cx.background_spawn({
let fs = fs.clone();
async move {
for theme_path in themes_to_add.into_iter() {
@ -1211,8 +1206,7 @@ impl ExtensionStore {
}
for snippets_path in &snippets_to_add {
if let Some(snippets_contents) = fs.load(snippets_path).await.log_err()
{
if let Some(snippets_contents) = fs.load(snippets_path).await.log_err() {
proxy
.register_snippet(snippets_path, &snippets_contents)
.log_err();
@ -1304,7 +1298,7 @@ impl ExtensionStore {
let extensions_dir = self.installed_dir.clone();
let index_path = self.index_path.clone();
let proxy = self.proxy.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let start_time = Instant::now();
let mut index = ExtensionIndex::default();
@ -1494,7 +1488,7 @@ impl ExtensionStore {
return Task::ready(Err(anyhow!("extension no longer installed")));
};
let fs = self.fs.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
const EXTENSION_TOML: &str = "extension.toml";
const EXTENSION_WASM: &str = "extension.wasm";
const CONFIG_TOML: &str = "config.toml";

View file

@ -1,5 +1,5 @@
use client::telemetry;
use gpui::{App, Task, Window};
use gpui::{App, AppContext as _, Task, Window};
use human_bytes::human_bytes;
use release_channel::{AppCommitSha, AppVersion, ReleaseChannel};
use serde::Serialize;
@ -44,7 +44,7 @@ impl SystemSpecs {
None
};
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let os_version = telemetry::os_version();
SystemSpecs {
app_version,

View file

@ -127,7 +127,7 @@ impl FileFinder {
let abs_path = abs_path?;
if project.is_local() {
let fs = fs.clone();
Some(cx.background_executor().spawn(async move {
Some(cx.background_spawn(async move {
if fs.is_file(&abs_path).await {
Some(FoundPath::new(project_path, Some(abs_path)))
} else {

View file

@ -337,7 +337,7 @@ impl GitPanel {
fn serialize(&mut self, cx: &mut Context<Self>) {
let width = self.width;
self.pending_serialization = cx.background_executor().spawn(
self.pending_serialization = cx.background_spawn(
async move {
KEY_VALUE_STORE
.write_kvp(
@ -1055,8 +1055,7 @@ impl GitPanel {
let task = if self.has_staged_changes() {
// Repository serializes all git operations, so we can just send a commit immediately
let commit_task = active_repository.read(cx).commit(message.into(), None);
cx.background_executor()
.spawn(async move { commit_task.await? })
cx.background_spawn(async move { commit_task.await? })
} else {
let changed_files = self
.entries

View file

@ -7,7 +7,7 @@ use editor::{scroll::Autoscroll, Editor, EditorEvent, ToPoint};
use feature_flags::FeatureFlagViewExt;
use futures::StreamExt;
use gpui::{
actions, AnyElement, AnyView, App, AppContext, AsyncWindowContext, Entity, EventEmitter,
actions, AnyElement, AnyView, App, AppContext as _, AsyncWindowContext, Entity, EventEmitter,
FocusHandle, Focusable, Render, Subscription, Task, WeakEntity,
};
use language::{Anchor, Buffer, Capability, OffsetRangeExt, Point};

View file

@ -177,8 +177,7 @@ impl PickerDelegate for RepositorySelectorDelegate {
cx.spawn_in(window, |this, mut cx| async move {
let filtered_repositories = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
if query.is_empty() {
all_repositories
} else {

View file

@ -252,7 +252,7 @@ impl SerializableItem for ImageView {
let workspace_id = workspace.database_id()?;
let image_path = self.image_item.read(cx).file.as_local()?.abs_path(cx);
Some(cx.background_executor().spawn({
Some(cx.background_spawn({
async move {
IMAGE_VIEWER
.save_image_path(item_id, workspace_id, image_path)

View file

@ -2,7 +2,7 @@ use anyhow::Result;
use chrono::{Datelike, Local, NaiveTime, Timelike};
use editor::scroll::Autoscroll;
use editor::Editor;
use gpui::{actions, App, Context, Window};
use gpui::{actions, App, AppContext as _, Context, Window};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use settings::{Settings, SettingsSources};
@ -87,7 +87,7 @@ pub fn new_journal_entry(workspace: &Workspace, window: &mut Window, cx: &mut Ap
let now = now.time();
let entry_heading = heading_entry(now, &settings.hour_format);
let create_entry = cx.background_executor().spawn(async move {
let create_entry = cx.background_spawn(async move {
std::fs::create_dir_all(month_dir)?;
OpenOptions::new()
.create(true)

View file

@ -940,7 +940,7 @@ impl Buffer {
}
let text_operations = self.text.operations().clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let since = since.unwrap_or_default();
operations.extend(
text_operations
@ -1135,7 +1135,7 @@ impl Buffer {
let old_snapshot = self.text.snapshot();
let mut branch_buffer = self.text.branch();
let mut syntax_snapshot = self.syntax_map.lock().snapshot();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
if !edits.is_empty() {
if let Some(language) = language.clone() {
syntax_snapshot.reparse(&old_snapshot, registry.clone(), language);
@ -1499,7 +1499,7 @@ impl Buffer {
let mut syntax_snapshot = syntax_map.snapshot();
drop(syntax_map);
let parse_task = cx.background_executor().spawn({
let parse_task = cx.background_spawn({
let language = language.clone();
let language_registry = language_registry.clone();
async move {
@ -1578,7 +1578,7 @@ impl Buffer {
fn request_autoindent(&mut self, cx: &mut Context<Self>) {
if let Some(indent_sizes) = self.compute_autoindents() {
let indent_sizes = cx.background_executor().spawn(indent_sizes);
let indent_sizes = cx.background_spawn(indent_sizes);
match cx
.background_executor()
.block_with_timeout(Duration::from_micros(500), indent_sizes)
@ -1907,7 +1907,7 @@ impl Buffer {
let old_text = self.as_rope().clone();
let line_ending = self.line_ending();
let base_version = self.version();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let ranges = trailing_whitespace_ranges(&old_text);
let empty = Arc::<str>::from("");
Diff {

View file

@ -940,6 +940,8 @@ impl LanguageRegistry {
binary: lsp::LanguageServerBinary,
cx: gpui::AsyncApp,
) -> Option<lsp::LanguageServer> {
use gpui::AppContext as _;
let mut state = self.state.write();
let fake_entry = state.fake_server_entries.get_mut(&name)?;
let (server, mut fake_server) = lsp::FakeLanguageServer::new(
@ -956,8 +958,7 @@ impl LanguageRegistry {
}
let tx = fake_entry.tx.clone();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
if fake_server
.try_receive_notification::<lsp::notification::Initialized>()
.await

View file

@ -3,7 +3,9 @@ use std::io::{Cursor, Write};
use crate::role::Role;
use crate::LanguageModelToolUse;
use base64::write::EncoderWriter;
use gpui::{point, size, App, DevicePixels, Image, ObjectFit, RenderImage, Size, Task};
use gpui::{
point, size, App, AppContext as _, DevicePixels, Image, ObjectFit, RenderImage, Size, Task,
};
use image::{codecs::png::PngEncoder, imageops::resize, DynamicImage, ImageDecoder};
use serde::{Deserialize, Serialize};
use ui::{px, SharedString};
@ -30,7 +32,7 @@ const ANTHROPIC_SIZE_LIMT: f32 = 1568.;
impl LanguageModelImage {
pub fn from_image(data: Image, cx: &mut App) -> Task<Option<Self>> {
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
match data.format() {
gpui::ImageFormat::Png
| gpui::ImageFormat::Jpeg

View file

@ -228,8 +228,7 @@ impl PickerDelegate for LanguageModelPickerDelegate {
cx.spawn_in(window, |this, mut cx| async move {
let filtered_models = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
let displayed_models = if configured_providers.is_empty() {
all_models
} else {

View file

@ -252,8 +252,7 @@ pub fn count_anthropic_tokens(
request: LanguageModelRequest,
cx: &App,
) -> BoxFuture<'static, Result<usize>> {
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let messages = request.messages;
let mut tokens_from_images = 0;
let mut string_messages = Vec::with_capacity(messages.len());

View file

@ -3,7 +3,8 @@ use collections::BTreeMap;
use editor::{Editor, EditorElement, EditorStyle};
use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt};
use gpui::{
AnyView, AppContext, AsyncApp, Entity, FontStyle, Subscription, Task, TextStyle, WhiteSpace,
AnyView, AppContext as _, AsyncApp, Entity, FontStyle, Subscription, Task, TextStyle,
WhiteSpace,
};
use http_client::HttpClient;
use language_model::{
@ -269,8 +270,7 @@ impl LanguageModel for DeepSeekLanguageModel {
request: LanguageModelRequest,
cx: &App,
) -> BoxFuture<'static, Result<usize>> {
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let messages = request
.messages
.into_iter()

View file

@ -330,8 +330,7 @@ pub fn count_google_tokens(
) -> BoxFuture<'static, Result<usize>> {
// We couldn't use the GoogleLanguageModelProvider to count tokens because the github copilot doesn't have the access to google_ai directly.
// So we have to use tokenizer from tiktoken_rs to count tokens.
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let messages = request
.messages
.into_iter()

View file

@ -281,8 +281,7 @@ impl LanguageModel for MistralLanguageModel {
request: LanguageModelRequest,
cx: &App,
) -> BoxFuture<'static, Result<usize>> {
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let messages = request
.messages
.into_iter()

View file

@ -343,8 +343,7 @@ pub fn count_open_ai_tokens(
model: open_ai::Model,
cx: &App,
) -> BoxFuture<'static, Result<usize>> {
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let messages = request
.messages
.into_iter()
@ -364,9 +363,7 @@ pub fn count_open_ai_tokens(
open_ai::Model::Custom { .. }
| open_ai::Model::O1Mini
| open_ai::Model::O1
| open_ai::Model::O3Mini => {
tiktoken_rs::num_tokens_from_messages("gpt-4", &messages)
}
| open_ai::Model::O3Mini => tiktoken_rs::num_tokens_from_messages("gpt-4", &messages),
_ => tiktoken_rs::num_tokens_from_messages(model.id(), &messages),
}
})

View file

@ -302,8 +302,7 @@ impl LivekitWindow {
if let Some(track) = self.screen_share_track.take() {
self.screen_share_stream.take();
let participant = self.room.local_participant();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
participant.unpublish_track(&track.sid()).await.unwrap();
})
.detach();

View file

@ -1,7 +1,9 @@
use crate::track::RemoteVideoTrack;
use anyhow::Result;
use futures::StreamExt as _;
use gpui::{AppContext, Context, Empty, Entity, EventEmitter, IntoElement, Render, Task, Window};
use gpui::{
AppContext as _, Context, Empty, Entity, EventEmitter, IntoElement, Render, Task, Window,
};
pub struct RemoteVideoTrackView {
track: RemoteVideoTrack,

View file

@ -6,7 +6,7 @@ pub use lsp_types::*;
use anyhow::{anyhow, Context as _, Result};
use collections::HashMap;
use futures::{channel::oneshot, io::BufWriter, select, AsyncRead, AsyncWrite, Future, FutureExt};
use gpui::{App, AsyncApp, BackgroundExecutor, SharedString, Task};
use gpui::{App, AppContext as _, AsyncApp, BackgroundExecutor, SharedString, Task};
use notification::DidChangeWorkspaceFolders;
use parking_lot::{Mutex, RwLock};
use postage::{barrier, prelude::Stream};
@ -448,7 +448,7 @@ impl LanguageServer {
let (stdout, stderr) = futures::join!(stdout_input_task, stderr_input_task);
stdout.or(stderr)
});
let output_task = cx.background_executor().spawn({
let output_task = cx.background_spawn({
Self::handle_output(
stdin,
outbound_rx,

View file

@ -178,7 +178,7 @@ impl Markdown {
let text = self.source.clone();
let parse_text_only = self.options.parse_links_only;
let parsed = cx.background_executor().spawn(async move {
let parsed = cx.background_spawn(async move {
let text = SharedString::from(text);
let events = match parse_text_only {
true => Arc::from(parse_links_only(text.as_ref())),

View file

@ -383,7 +383,7 @@ impl MarkdownPreviewView {
(contents, file_location)
})?;
let parsing_task = cx.background_executor().spawn(async move {
let parsing_task = cx.background_spawn(async move {
parse_markdown(&contents, file_location, Some(language_registry)).await
});
let contents = parsing_task.await;

View file

@ -13,7 +13,7 @@ use buffer_diff::{
use clock::ReplicaId;
use collections::{BTreeMap, Bound, HashMap, HashSet};
use futures::{channel::mpsc, SinkExt};
use gpui::{App, Context, Entity, EntityId, EventEmitter, Task};
use gpui::{App, AppContext as _, Context, Entity, EntityId, EventEmitter, Task};
use itertools::Itertools;
use language::{
language_settings::{language_settings, IndentGuideSettings, LanguageSettings},
@ -51,9 +51,6 @@ use text::{
use theme::SyntaxTheme;
use util::post_inc;
#[cfg(any(test, feature = "test-support"))]
use gpui::AppContext as _;
const NEWLINES: &[u8] = &[b'\n'; u8::MAX as usize];
#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
@ -1580,8 +1577,7 @@ impl MultiBuffer {
buffer_ids.push(buffer_id);
cx.background_executor()
.spawn({
cx.background_spawn({
let mut excerpt_ranges_tx = excerpt_ranges_tx.clone();
async move {

View file

@ -171,7 +171,7 @@ impl SearchState {
})
.collect(),
highlight_search_match_tx,
_search_match_highlighter: cx.background_executor().spawn(async move {
_search_match_highlighter: cx.background_spawn(async move {
while let Ok(highlight_arguments) = highlight_search_match_rx.recv().await {
let needs_init = highlight_arguments.search_data.get().is_none();
let search_data = highlight_arguments.search_data.get_or_init(|| {
@ -681,8 +681,7 @@ impl OutlinePanel {
mut cx: AsyncWindowContext,
) -> anyhow::Result<Entity<Self>> {
let serialized_panel = cx
.background_executor()
.spawn(async move { KEY_VALUE_STORE.read_kvp(OUTLINE_PANEL_KEY) })
.background_spawn(async move { KEY_VALUE_STORE.read_kvp(OUTLINE_PANEL_KEY) })
.await
.context("loading outline panel")
.log_err()
@ -849,7 +848,7 @@ impl OutlinePanel {
fn serialize(&mut self, cx: &mut Context<Self>) {
let width = self.width;
let active = Some(self.active);
self.pending_serialization = cx.background_executor().spawn(
self.pending_serialization = cx.background_spawn(
async move {
KEY_VALUE_STORE
.write_kvp(
@ -2631,8 +2630,7 @@ impl OutlinePanel {
new_depth_map,
new_children_count,
)) = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
let mut processed_external_buffers = HashSet::default();
let mut new_worktree_entries =
BTreeMap::<WorktreeId, HashMap<ProjectEntryId, GitEntry>>::default();
@ -3224,8 +3222,7 @@ impl OutlinePanel {
(buffer_id, excerpt_id),
cx.spawn_in(window, |outline_panel, mut cx| async move {
let fetched_outlines = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
buffer_snapshot
.outline_items_containing(
excerpt_range.context,

View file

@ -346,7 +346,7 @@ impl RemoteBufferStore {
fn open_unstaged_diff(&self, buffer_id: BufferId, cx: &App) -> Task<Result<Option<String>>> {
let project_id = self.project_id;
let client = self.upstream_client.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let response = client
.request(proto::OpenUnstagedDiff {
project_id,
@ -366,7 +366,7 @@ impl RemoteBufferStore {
let project_id = self.project_id;
let client = self.upstream_client.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let response = client
.request(proto::OpenUncommittedDiff {
project_id,
@ -402,9 +402,7 @@ impl RemoteBufferStore {
return Ok(buffer);
}
cx.background_executor()
.spawn(async move { rx.await? })
.await
cx.background_spawn(async move { rx.await? }).await
})
}
@ -843,8 +841,7 @@ impl LocalBufferStore {
let snapshot =
worktree_handle.update(&mut cx, |tree, _| tree.as_local().unwrap().snapshot())?;
let diff_bases_changes_by_buffer = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
diff_state_updates
.into_iter()
.filter_map(
@ -1129,8 +1126,7 @@ impl LocalBufferStore {
cx.spawn(move |_, mut cx| async move {
let loaded = load_file.await?;
let text_buffer = cx
.background_executor()
.spawn(async move { text::Buffer::new(0, buffer_id, loaded.text) })
.background_spawn(async move { text::Buffer::new(0, buffer_id, loaded.text) })
.await;
cx.insert_entity(reservation, |_| {
Buffer::build(text_buffer, Some(loaded.file), Capability::ReadWrite)
@ -1347,8 +1343,7 @@ impl BufferStore {
}
};
cx.background_executor()
.spawn(async move { task.await.map_err(|e| anyhow!("{e}")) })
cx.background_spawn(async move { task.await.map_err(|e| anyhow!("{e}")) })
}
pub fn open_unstaged_diff(
@ -1388,8 +1383,7 @@ impl BufferStore {
}
};
cx.background_executor()
.spawn(async move { task.await.map_err(|e| anyhow!("{e}")) })
cx.background_spawn(async move { task.await.map_err(|e| anyhow!("{e}")) })
}
pub fn open_uncommitted_diff(
@ -1409,7 +1403,7 @@ impl BufferStore {
BufferStoreState::Local(this) => {
let committed_text = this.load_committed_text(&buffer, cx);
let staged_text = this.load_staged_text(&buffer, cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let committed_text = committed_text.await?;
let staged_text = staged_text.await?;
let diff_bases_change = if committed_text == staged_text {
@ -1445,8 +1439,7 @@ impl BufferStore {
}
};
cx.background_executor()
.spawn(async move { task.await.map_err(|e| anyhow!("{e}")) })
cx.background_spawn(async move { task.await.map_err(|e| anyhow!("{e}")) })
}
async fn open_diff_internal(
@ -1587,7 +1580,7 @@ impl BufferStore {
anyhow::Ok(Some((repo, relative_path, content)))
});
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let Some((repo, relative_path, content)) = blame_params? else {
return Ok(None);
};
@ -2106,8 +2099,7 @@ impl BufferStore {
})
.log_err();
cx.background_executor()
.spawn(
cx.background_spawn(
async move {
let operations = operations.await;
for chunk in split_operations(operations) {
@ -2558,8 +2550,7 @@ impl BufferStore {
if client.send(initial_state).log_err().is_some() {
let client = client.clone();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let mut chunks = split_operations(operations).peekable();
while let Some(chunk) = chunks.next() {
let is_last = chunks.peek().is_none();

View file

@ -135,8 +135,7 @@ impl ProjectEnvironment {
cx.spawn(|this, mut cx| async move {
let (mut shell_env, error_message) = cx
.background_executor()
.spawn({
.background_spawn({
let worktree_abs_path = worktree_abs_path.clone();
async move {
load_worktree_shell_environment(&worktree_abs_path, &load_direnv).await

View file

@ -11,8 +11,8 @@ use git::{
status::{GitSummary, TrackedSummary},
};
use gpui::{
App, AppContext, AsyncApp, Context, Entity, EventEmitter, SharedString, Subscription, Task,
WeakEntity,
App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, SharedString, Subscription,
Task, WeakEntity,
};
use language::{Buffer, LanguageRegistry};
use rpc::proto::{git_reset, ToProto};
@ -242,10 +242,7 @@ impl GitStore {
mpsc::unbounded::<(Message, oneshot::Sender<Result<()>>)>();
cx.spawn(|_, cx| async move {
while let Some((msg, respond)) = update_receiver.next().await {
let result = cx
.background_executor()
.spawn(Self::process_git_msg(msg))
.await;
let result = cx.background_spawn(Self::process_git_msg(msg)).await;
respond.send(result).ok();
}
})
@ -841,15 +838,14 @@ impl Repository {
match self.git_repo.clone() {
GitRepo::Local(git_repository) => {
let commit = commit.to_string();
cx.background_executor()
.spawn(async move { git_repository.show(&commit) })
cx.background_spawn(async move { git_repository.show(&commit) })
}
GitRepo::Remote {
project_id,
client,
worktree_id,
work_directory_id,
} => cx.background_executor().spawn(async move {
} => cx.background_spawn(async move {
let resp = client
.request(proto::GitShow {
project_id: project_id.0,

View file

@ -404,7 +404,7 @@ impl ImageStore {
}
};
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
Self::wait_for_loading_image(loading_watch)
.await
.map_err(|e| e.cloned())

View file

@ -2144,7 +2144,7 @@ impl LocalLspStore {
cx: &mut Context<LspStore>,
) -> Task<Result<Vec<(Range<Anchor>, String)>>> {
let snapshot = self.buffer_snapshot_for_lsp_version(buffer, server_id, version, cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let snapshot = snapshot?;
let mut lsp_edits = lsp_edits
.into_iter()
@ -3282,8 +3282,7 @@ impl LspStore {
}
} else if let Some((upstream_client, upstream_project_id)) = self.upstream_client() {
let buffer_id = buffer.read(cx).remote_id().to_proto();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
upstream_client
.request(proto::RegisterBufferWithLanguageServers {
project_id: upstream_project_id,
@ -6707,7 +6706,7 @@ impl LspStore {
return Err(anyhow!("No language server {id}"));
};
Ok(cx.background_executor().spawn(async move {
Ok(cx.background_spawn(async move {
let can_resolve = server
.capabilities()
.completion_provider
@ -7375,9 +7374,7 @@ impl LspStore {
.map(|b| b.read(cx).remote_id().to_proto())
.collect(),
});
cx.background_executor()
.spawn(request)
.detach_and_log_err(cx);
cx.background_spawn(request).detach_and_log_err(cx);
} else {
let Some(local) = self.as_local_mut() else {
return;
@ -7406,9 +7403,7 @@ impl LspStore {
.collect::<Vec<_>>();
cx.spawn(|this, mut cx| async move {
cx.background_executor()
.spawn(futures::future::join_all(tasks))
.await;
cx.background_spawn(futures::future::join_all(tasks)).await;
this.update(&mut cx, |this, cx| {
for buffer in buffers {
this.register_buffer_with_language_servers(&buffer, true, cx);
@ -7737,9 +7732,7 @@ impl LspStore {
},
)),
});
cx.background_executor()
.spawn(request)
.detach_and_log_err(cx);
cx.background_spawn(request).detach_and_log_err(cx);
} else if let Some(local) = self.as_local() {
let servers = buffers
.into_iter()
@ -7795,9 +7788,7 @@ impl LspStore {
),
),
});
cx.background_executor()
.spawn(request)
.detach_and_log_err(cx);
cx.background_spawn(request).detach_and_log_err(cx);
}
}

View file

@ -12,7 +12,7 @@ use futures::{
stream::FuturesUnordered,
FutureExt,
};
use gpui::{AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity};
use gpui::{AppContext as _, AsyncApp, Context, Entity, EventEmitter, Task, WeakEntity};
use language::{
language_settings::{Formatter, LanguageSettings, SelectedFormatter},
Buffer, LanguageRegistry, LocalFile,
@ -121,8 +121,7 @@ impl PrettierStore {
let installed_prettiers = self.prettier_instances.keys().cloned().collect();
cx.spawn(|lsp_store, mut cx| async move {
match cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
Prettier::locate_prettier_installation(
fs.as_ref(),
&installed_prettiers,
@ -234,8 +233,7 @@ impl PrettierStore {
.unwrap_or_default();
cx.spawn(|lsp_store, mut cx| async move {
match cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
Prettier::locate_prettier_ignore(
fs.as_ref(),
&prettier_ignores,
@ -483,8 +481,7 @@ impl PrettierStore {
}))
.collect::<Vec<_>>();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let _: Vec<()> = future::join_all(prettiers_to_reload.into_iter().map(|(worktree_id, prettier_path, prettier_instance)| {
async move {
if let Some(instance) = prettier_instance.prettier {
@ -539,7 +536,7 @@ impl PrettierStore {
}) {
Some(locate_from) => {
let installed_prettiers = self.prettier_instances.keys().cloned().collect();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
Prettier::locate_prettier_installation(
fs.as_ref(),
&installed_prettiers,
@ -631,8 +628,7 @@ impl PrettierStore {
})?;
if needs_install {
let installed_plugins = new_plugins.clone();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
install_prettier_packages(fs.as_ref(), new_plugins, node).await?;
// Save the server file last, so the reinstall need could be determined by the absence of the file.
save_prettier_server_file(fs.as_ref()).await?;

View file

@ -562,7 +562,7 @@ impl DirectoryLister {
}
DirectoryLister::Local(fs) => {
let fs = fs.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let mut results = vec![];
let expanded = shellexpand::tilde(&path);
let query = Path::new(expanded.as_ref());
@ -1163,8 +1163,7 @@ impl Project {
.read(cx)
.shutdown_processes(Some(proto::ShutdownRemoteServer {}));
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
if let Some(shutdown) = shutdown {
shutdown.await;
}
@ -3138,7 +3137,7 @@ impl Project {
let buffer = buffer.clone();
let query = query.clone();
let snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot())?;
chunk_results.push(cx.background_executor().spawn(async move {
chunk_results.push(cx.background_spawn(async move {
let ranges = query
.search(&snapshot, None)
.await
@ -3377,7 +3376,7 @@ impl Project {
cx: &mut Context<Self>,
) -> Task<Option<ResolvedPath>> {
let resolve_task = self.resolve_abs_path(path, cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let resolved_path = resolve_task.await;
resolved_path.filter(|path| path.is_file())
})
@ -3391,7 +3390,7 @@ impl Project {
if self.is_local() {
let expanded = PathBuf::from(shellexpand::tilde(&path).into_owned());
let fs = self.fs.clone();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let path = expanded.as_path();
let metadata = fs.metadata(path).await.ok().flatten();
@ -3409,7 +3408,7 @@ impl Project {
project_id: SSH_PROJECT_ID,
path: request_path.to_proto(),
});
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let response = request.await.log_err()?;
if response.exists {
Some(ResolvedPath::AbsPath {
@ -3490,7 +3489,7 @@ impl Project {
};
let response = session.read(cx).proto_client().request(request);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let response = response.await?;
Ok(response.entries.into_iter().map(PathBuf::from).collect())
})
@ -3906,8 +3905,7 @@ impl Project {
if let Some(remote_id) = this.remote_id() {
let mut payload = envelope.payload.clone();
payload.project_id = remote_id;
cx.background_executor()
.spawn(this.client.request(payload))
cx.background_spawn(this.client.request(payload))
.detach_and_log_err(cx);
}
this.buffer_store.clone()
@ -3924,8 +3922,7 @@ impl Project {
if let Some(ssh) = &this.ssh_client {
let mut payload = envelope.payload.clone();
payload.project_id = SSH_PROJECT_ID;
cx.background_executor()
.spawn(ssh.read(cx).proto_client().request(payload))
cx.background_spawn(ssh.read(cx).proto_client().request(payload))
.detach_and_log_err(cx);
}
this.buffer_store.clone()
@ -4146,7 +4143,7 @@ impl Project {
if let Some(buffer) = this.buffer_for_id(buffer_id, cx) {
let operations =
buffer.read(cx).serialize_ops(Some(remote_version), cx);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let operations = operations.await;
for chunk in split_operations(operations) {
client
@ -4169,8 +4166,7 @@ impl Project {
// Any incomplete buffers have open requests waiting. Request that the host sends
// creates these buffers for us again to unblock any waiting futures.
for id in incomplete_buffer_ids {
cx.background_executor()
.spawn(client.request(proto::OpenBufferById {
cx.background_spawn(client.request(proto::OpenBufferById {
project_id,
id: id.into(),
}))

View file

@ -13,7 +13,7 @@ use std::{
};
use collections::HashMap;
use gpui::{App, AppContext, Context, Entity, EventEmitter, Subscription};
use gpui::{App, AppContext as _, Context, Entity, EventEmitter, Subscription};
use language::{CachedLspAdapter, LspAdapterDelegate};
use lsp::LanguageServerName;
use path_trie::{LabelPresence, RootPathTrie, TriePath};

View file

@ -15,7 +15,7 @@ use std::{
};
use collections::{HashMap, IndexMap};
use gpui::{App, AppContext, Entity, Subscription};
use gpui::{App, AppContext as _, Entity, Subscription};
use itertools::Itertools;
use language::{
language_settings::AllLanguageSettings, Attach, LanguageName, LanguageRegistry,

View file

@ -325,8 +325,7 @@ impl LocalToolchainStore {
.ok()?
.await;
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let language = registry
.language_for_name(language_name.as_ref())
.await

View file

@ -13,7 +13,9 @@ use futures::{
FutureExt, SinkExt,
};
use git::repository::Branch;
use gpui::{App, AsyncApp, Context, Entity, EntityId, EventEmitter, Task, WeakEntity};
use gpui::{
App, AppContext as _, AsyncApp, Context, Entity, EntityId, EventEmitter, Task, WeakEntity,
};
use postage::oneshot;
use rpc::{
proto::{self, FromProto, ToProto, SSH_PROJECT_ID},
@ -179,8 +181,7 @@ impl WorktreeStore {
Task::ready(Ok((tree, relative_path)))
} else {
let worktree = self.create_worktree(abs_path, visible, cx);
cx.background_executor()
.spawn(async move { Ok((worktree.await?, PathBuf::new())) })
cx.background_spawn(async move { Ok((worktree.await?, PathBuf::new())) })
}
}
@ -679,7 +680,7 @@ impl WorktreeStore {
let (output_tx, output_rx) = smol::channel::bounded(64);
let (matching_paths_tx, matching_paths_rx) = smol::channel::unbounded();
let input = cx.background_executor().spawn({
let input = cx.background_spawn({
let fs = fs.clone();
let query = query.clone();
async move {
@ -696,7 +697,7 @@ impl WorktreeStore {
}
});
const MAX_CONCURRENT_FILE_SCANS: usize = 64;
let filters = cx.background_executor().spawn(async move {
let filters = cx.background_spawn(async move {
let fs = &fs;
let query = &query;
executor
@ -712,8 +713,7 @@ impl WorktreeStore {
})
.await;
});
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let mut matched = 0;
while let Ok(mut receiver) = output_rx.recv().await {
let Some(path) = receiver.next().await else {
@ -934,7 +934,7 @@ impl WorktreeStore {
}),
});
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let response = request.await?;
let branches = response
@ -1021,7 +1021,7 @@ impl WorktreeStore {
branch_name: new_branch,
});
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
request.await?;
Ok(())
})

View file

@ -544,8 +544,7 @@ impl ProjectPanel {
mut cx: AsyncWindowContext,
) -> Result<Entity<Self>> {
let serialized_panel = cx
.background_executor()
.spawn(async move { KEY_VALUE_STORE.read_kvp(PROJECT_PANEL_KEY) })
.background_spawn(async move { KEY_VALUE_STORE.read_kvp(PROJECT_PANEL_KEY) })
.await
.map_err(|e| anyhow!("Failed to load project panel: {}", e))
.log_err()
@ -627,7 +626,7 @@ impl ProjectPanel {
fn serialize(&mut self, cx: &mut Context<Self>) {
let width = self.width;
self.pending_serialization = cx.background_executor().spawn(
self.pending_serialization = cx.background_spawn(
async move {
KEY_VALUE_STORE
.write_kvp(

View file

@ -218,8 +218,7 @@ impl PickerDelegate for PromptPickerDelegate {
let prev_prompt_id = self.matches.get(self.selected_index).map(|mat| mat.id);
cx.spawn_in(window, |this, mut cx| async move {
let (matches, selected_index) = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
let matches = search.await;
let selected_index = prev_prompt_id

View file

@ -2,7 +2,7 @@ use anyhow::Result;
use assets::Assets;
use fs::Fs;
use futures::StreamExt;
use gpui::{App, AssetSource};
use gpui::{App, AppContext as _, AssetSource};
use handlebars::{Handlebars, RenderError};
use language::{BufferSnapshot, LanguageName, Point};
use parking_lot::Mutex;
@ -103,8 +103,7 @@ impl PromptBuilder {
handlebars: Arc<Mutex<Handlebars<'static>>>,
) {
let templates_dir = paths::prompt_overrides_dir(params.repo_path.as_deref());
params.cx.background_executor()
.spawn(async move {
params.cx.background_spawn(async move {
let Some(parent_dir) = templates_dir.parent() else {
return;
};

View file

@ -17,7 +17,7 @@ use futures::{
select, select_biased, AsyncReadExt as _, Future, FutureExt as _, StreamExt as _,
};
use gpui::{
App, AppContext, AsyncApp, BorrowAppContext, Context, Entity, EventEmitter, Global,
App, AppContext as _, AsyncApp, BorrowAppContext, Context, Entity, EventEmitter, Global,
SemanticVersion, Task, WeakEntity,
};
use itertools::Itertools;
@ -1158,8 +1158,7 @@ impl SshRemoteClient {
c.connections.insert(
opts.clone(),
ConnectionPoolEntry::Connecting(
cx.background_executor()
.spawn({
cx.background_spawn({
let connection = connection.clone();
async move { Ok(connection.clone()) }
})
@ -1358,7 +1357,7 @@ impl RemoteConnection for SshRemoteConnection {
))
.output();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
let output = output.await?;
if !output.status.success() {
@ -1679,14 +1678,14 @@ impl SshRemoteConnection {
let mut stderr_buffer = Vec::new();
let mut stderr_offset = 0;
let stdin_task = cx.background_executor().spawn(async move {
let stdin_task = cx.background_spawn(async move {
while let Some(outgoing) = outgoing_rx.next().await {
write_message(&mut child_stdin, &mut stdin_buffer, outgoing).await?;
}
anyhow::Ok(())
});
let stdout_task = cx.background_executor().spawn({
let stdout_task = cx.background_spawn({
let mut connection_activity_tx = connection_activity_tx.clone();
async move {
loop {
@ -1711,7 +1710,7 @@ impl SshRemoteConnection {
}
});
let stderr_task: Task<anyhow::Result<()>> = cx.background_executor().spawn(async move {
let stderr_task: Task<anyhow::Result<()>> = cx.background_spawn(async move {
loop {
stderr_buffer.resize(stderr_offset + 1024, 0);
@ -2449,7 +2448,7 @@ mod fake {
},
select_biased, FutureExt, SinkExt, StreamExt,
};
use gpui::{App, AsyncApp, SemanticVersion, Task, TestAppContext};
use gpui::{App, AppContext as _, AsyncApp, SemanticVersion, Task, TestAppContext};
use release_channel::ReleaseChannel;
use rpc::proto::Envelope;
@ -2533,7 +2532,7 @@ mod fake {
&self.server_cx.get(cx),
);
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
loop {
select_biased! {
server_to_client = server_outgoing_rx.next().fuse() => {

View file

@ -240,8 +240,7 @@ impl HeadlessProject {
operation,
is_local: true,
} => cx
.background_executor()
.spawn(self.session.request(proto::UpdateBuffer {
.background_spawn(self.session.request(proto::UpdateBuffer {
project_id: SSH_PROJECT_ID,
buffer_id: buffer.read(cx).remote_id().to_proto(),
operations: vec![serialize_operation(operation)],
@ -302,8 +301,7 @@ impl HeadlessProject {
message: prompt.message.clone(),
});
let prompt = prompt.clone();
cx.background_executor()
.spawn(async move {
cx.background_spawn(async move {
let response = request.await?;
if let Some(action_response) = response.action_response {
prompt.respond(action_response as usize).await;

View file

@ -311,7 +311,7 @@ fn start_server(
let mut output_buffer = Vec::new();
let (mut stdin_msg_tx, mut stdin_msg_rx) = mpsc::unbounded::<Envelope>();
cx.background_executor().spawn(async move {
cx.background_spawn(async move {
while let Ok(msg) = read_message(&mut stdin_stream, &mut input_buffer).await {
if let Err(_) = stdin_msg_tx.send(msg).await {
break;
@ -487,8 +487,7 @@ pub fn execute_run(
handle_panic_requests(&project, &session);
cx.background_executor()
.spawn(async move { cleanup_old_binaries() })
cx.background_spawn(async move { cleanup_old_binaries() })
.detach();
mem::forget(project);

View file

@ -5,7 +5,7 @@ use futures::{
stream::{SelectAll, StreamExt},
AsyncBufReadExt as _, SinkExt as _,
};
use gpui::{App, Entity, EntityId, Task, Window};
use gpui::{App, AppContext as _, Entity, EntityId, Task, Window};
use jupyter_protocol::{
connection_info::{ConnectionInfo, Transport},
ExecutionState, JupyterKernelspec, JupyterMessage, JupyterMessageContent, KernelInfoReply,
@ -211,7 +211,7 @@ impl NativeRunningKernel {
futures::channel::mpsc::channel(100);
let (mut shell_request_tx, mut shell_request_rx) = futures::channel::mpsc::channel(100);
let routing_task = cx.background_executor().spawn({
let routing_task = cx.background_spawn({
async move {
while let Some(message) = request_rx.next().await {
match message.content {
@ -229,7 +229,7 @@ impl NativeRunningKernel {
}
});
let shell_task = cx.background_executor().spawn({
let shell_task = cx.background_spawn({
async move {
while let Some(message) = shell_request_rx.next().await {
shell_socket.send(message).await.ok();
@ -240,7 +240,7 @@ impl NativeRunningKernel {
}
});
let control_task = cx.background_executor().spawn({
let control_task = cx.background_spawn({
async move {
while let Some(message) = control_request_rx.next().await {
control_socket.send(message).await.ok();

View file

@ -1,5 +1,5 @@
use futures::{channel::mpsc, SinkExt as _};
use gpui::{App, Entity, Task, Window};
use gpui::{App, AppContext as _, Entity, Task, Window};
use http_client::{AsyncBody, HttpClient, Request};
use jupyter_protocol::{ExecutionState, JupyterKernelspec, JupyterMessage, KernelInfoReply};
@ -189,7 +189,7 @@ impl RemoteRunningKernel {
let (request_tx, mut request_rx) =
futures::channel::mpsc::channel::<JupyterMessage>(100);
let routing_task = cx.background_executor().spawn({
let routing_task = cx.background_spawn({
async move {
while let Some(message) = request_rx.next().await {
w.send(message).await.ok();

View file

@ -134,8 +134,7 @@ impl Cell {
cx.spawn_in(window, |this, mut cx| async move {
let parsed_markdown = cx
.background_executor()
.spawn(async move {
.background_spawn(async move {
parse_markdown(&source, None, Some(languages)).await
})
.await;

View file

@ -19,9 +19,8 @@ impl MarkdownView {
pub fn from(text: String, cx: &mut Context<Self>) -> Self {
let task = cx.spawn(|markdown_view, mut cx| {
let text = text.clone();
let parsed = cx
.background_executor()
.spawn(async move { parse_markdown(&text, None, None).await });
let parsed =
cx.background_spawn(async move { parse_markdown(&text, None, None).await });
async move {
let content = parsed.await;

Some files were not shown because too many files have changed in this diff Show more