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
|
@ -1304,8 +1304,8 @@ impl Buffer {
|
|||
pub fn reload(&mut self, cx: &Context<Self>) -> oneshot::Receiver<Option<Transaction>> {
|
||||
let (tx, rx) = futures::channel::oneshot::channel();
|
||||
let prev_version = self.text.version();
|
||||
self.reload_task = Some(cx.spawn(|this, mut cx| async move {
|
||||
let Some((new_mtime, new_text)) = this.update(&mut cx, |this, cx| {
|
||||
self.reload_task = Some(cx.spawn(async move |this, cx| {
|
||||
let Some((new_mtime, new_text)) = this.update(cx, |this, cx| {
|
||||
let file = this.file.as_ref()?.as_local()?;
|
||||
Some((file.disk_state().mtime(), file.load(cx)))
|
||||
})?
|
||||
|
@ -1315,9 +1315,9 @@ impl Buffer {
|
|||
|
||||
let new_text = new_text.await?;
|
||||
let diff = this
|
||||
.update(&mut cx, |this, cx| this.diff(new_text.clone(), cx))?
|
||||
.update(cx, |this, cx| this.diff(new_text.clone(), cx))?
|
||||
.await;
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.update(cx, |this, cx| {
|
||||
if this.version() == diff.base_version {
|
||||
this.finalize_last_transaction();
|
||||
this.apply_diff(diff, cx);
|
||||
|
@ -1499,9 +1499,9 @@ impl Buffer {
|
|||
self.reparse = None;
|
||||
}
|
||||
Err(parse_task) => {
|
||||
self.reparse = Some(cx.spawn(move |this, mut cx| async move {
|
||||
self.reparse = Some(cx.spawn(async move |this, cx| {
|
||||
let new_syntax_map = parse_task.await;
|
||||
this.update(&mut cx, move |this, cx| {
|
||||
this.update(cx, move |this, cx| {
|
||||
let grammar_changed =
|
||||
this.language.as_ref().map_or(true, |current_language| {
|
||||
!Arc::ptr_eq(&language, current_language)
|
||||
|
@ -1566,9 +1566,9 @@ impl Buffer {
|
|||
{
|
||||
Ok(indent_sizes) => self.apply_autoindents(indent_sizes, cx),
|
||||
Err(indent_sizes) => {
|
||||
self.pending_autoindent = Some(cx.spawn(|this, mut cx| async move {
|
||||
self.pending_autoindent = Some(cx.spawn(async move |this, cx| {
|
||||
let indent_sizes = indent_sizes.await;
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.update(cx, |this, cx| {
|
||||
this.apply_autoindents(indent_sizes, cx);
|
||||
})
|
||||
.ok();
|
||||
|
|
|
@ -940,7 +940,7 @@ impl LanguageRegistry {
|
|||
server_id: LanguageServerId,
|
||||
name: &LanguageServerName,
|
||||
binary: lsp::LanguageServerBinary,
|
||||
cx: gpui::AsyncApp,
|
||||
cx: &mut gpui::AsyncApp,
|
||||
) -> Option<lsp::LanguageServer> {
|
||||
use gpui::AppContext as _;
|
||||
|
||||
|
@ -951,7 +951,7 @@ impl LanguageRegistry {
|
|||
binary,
|
||||
name.0.to_string(),
|
||||
fake_entry.capabilities.clone(),
|
||||
cx.clone(),
|
||||
cx,
|
||||
);
|
||||
fake_entry._server = Some(fake_server.clone());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue