diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index 37bcdd8c84..4eecfcd840 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -134,7 +134,7 @@ impl DebugPanel { pane, size: px(300.), _subscriptions, - dap_store: DapStore::global(cx), + dap_store: project.read(cx).dap_store(), focus_handle: cx.focus_handle(), show_did_not_stop_warning: false, thread_states: Default::default(), diff --git a/crates/debugger_ui/src/lib.rs b/crates/debugger_ui/src/lib.rs index 6aecbc72d9..b35bdf0d64 100644 --- a/crates/debugger_ui/src/lib.rs +++ b/crates/debugger_ui/src/lib.rs @@ -2,7 +2,6 @@ use dap::debugger_settings::DebuggerSettings; use debugger_panel::{DebugPanel, ToggleFocus}; use debugger_panel_item::DebugPanelItem; use gpui::AppContext; -use project::dap_store::{self}; use settings::Settings; use ui::ViewContext; use workspace::{StartDebugger, Workspace}; @@ -14,7 +13,6 @@ mod variable_list; pub fn init(cx: &mut AppContext) { DebuggerSettings::register(cx); - dap_store::init(cx); cx.observe_new_views( |workspace: &mut Workspace, _cx: &mut ViewContext| { diff --git a/crates/project/src/dap_store.rs b/crates/project/src/dap_store.rs index 2924648671..52cac5a891 100644 --- a/crates/project/src/dap_store.rs +++ b/crates/project/src/dap_store.rs @@ -16,7 +16,7 @@ use dap::{ SteppingGranularity, TerminateArguments, TerminateThreadsArguments, Variable, VariablesArguments, }; -use gpui::{AppContext, Context, EventEmitter, Global, Model, ModelContext, Task}; +use gpui::{EventEmitter, ModelContext, Task}; use language::{Buffer, BufferSnapshot}; use serde_json::Value; use settings::WorktreeId; @@ -58,20 +58,7 @@ pub struct DapStore { impl EventEmitter for DapStore {} -struct GlobalDapStore(Model); - -impl Global for GlobalDapStore {} - -pub fn init(cx: &mut AppContext) { - let store = GlobalDapStore(cx.new_model(DapStore::new)); - cx.set_global(store); -} - impl DapStore { - pub fn global(cx: &AppContext) -> Model { - cx.global::().0.clone() - } - pub fn new(cx: &mut ModelContext) -> Self { cx.on_app_quit(Self::shutdown_clients).detach(); diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index e147b12b29..419fdbdb2c 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -640,8 +640,6 @@ impl Project { env: Option>, cx: &mut AppContext, ) -> Model { - let dap_store = DapStore::global(cx); - cx.new_model(|cx: &mut ModelContext| { let (tx, rx) = mpsc::unbounded(); cx.spawn(move |this, cx| Self::send_buffer_ordered_messages(this, rx, cx)) @@ -655,6 +653,8 @@ impl Project { cx.subscribe(&worktree_store, Self::on_worktree_store_event) .detach(); + let dap_store = cx.new_model(|cx| DapStore::new(cx)); + let buffer_store = cx.new_model(|cx| { BufferStore::new(worktree_store.clone(), None, dap_store.clone(), cx) }); @@ -743,8 +743,6 @@ impl Project { fs: Arc, cx: &mut AppContext, ) -> Model { - let dap_store = DapStore::global(cx); - cx.new_model(|cx: &mut ModelContext| { let (tx, rx) = mpsc::unbounded(); cx.spawn(move |this, cx| Self::send_buffer_ordered_messages(this, rx, cx)) @@ -759,6 +757,8 @@ impl Project { cx.subscribe(&worktree_store, Self::on_worktree_store_event) .detach(); + let dap_store = cx.new_model(|cx| DapStore::new(cx)); + let buffer_store = cx.new_model(|cx| { BufferStore::new(worktree_store.clone(), None, dap_store.clone(), cx) }); @@ -916,7 +916,7 @@ impl Project { store })?; - let dap_store = cx.update(|cx| DapStore::global(cx))?; + let dap_store = cx.new_model(|cx| DapStore::new(cx))?; let buffer_store = cx.new_model(|cx| { BufferStore::new(