Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
edit prediction: Assign providers when client status changes (#28919)
Agus Zubiagaa7a7335da4eb
diff --git a/crates/zed/src/zed/inline_completion_registry.rs b/crates/zed/src/zed/inline_completion_registry.rsindex 639644b087f..f2e9d21b96a 100644--- a/crates/zed/src/zed/inline_completion_registry.rs+++ b/crates/zed/src/zed/inline_completion_registry.rs@@ -5,9 +5,11 @@ use editor::Editor;use gpui::{AnyWindowHandle, App, AppContext as _, Context, Entity, WeakEntity};use language::language_settings::{EditPredictionProvider, all_language_settings};use settings::SettingsStore;+use smol::stream::StreamExt;use std::{cell::RefCell, rc::Rc, sync::Arc};use supermaven::{Supermaven, SupermavenCompletionProvider};use ui::Window;+use util::ResultExt;use workspace::Workspace;use zeta::{ProviderDataCollection, ZetaInlineCompletionProvider};@@ -54,24 +56,31 @@ pub fn init(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut App) {}).detach();+ cx.on_action(clear_zeta_edit_history);+let mut provider = all_language_settings(None, cx).edit_predictions.provider;- for (editor, window) in editors.borrow().iter() {- _ = window.update(cx, |_window, window, cx| {- _ = editor.update(cx, |editor, cx| {- assign_edit_prediction_provider(- editor,- provider,- &client,- user_store.clone(),- window,- cx,- );- })- });- }+ cx.spawn({+ let user_store = user_store.clone();+ let editors = editors.clone();+ let client = client.clone();- cx.on_action(clear_zeta_edit_history);- assign_edit_prediction_providers(&editors, provider, &client, user_store.clone(), cx);+ async move |cx| {+ let mut status = client.status();+ while let Some(_status) = status.next().await {+ cx.update(|cx| {+ assign_edit_prediction_providers(+ &editors,+ provider,+ &client,+ user_store.clone(),+ cx,+ );+ })+ .log_err();+ }+ }+ })+ .detach();cx.observe_global::<SettingsStore>({let editors = editors.clone();