Make test pass again

This commit is contained in:
Remco Smits
2024-09-21 19:25:11 +02:00
parent c26a8f1537
commit 4ddb65bdaa
4 changed files with 7 additions and 22 deletions

View File

@@ -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(),

View File

@@ -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<Workspace>| {

View File

@@ -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<DapStoreEvent> for DapStore {}
struct GlobalDapStore(Model<DapStore>);
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<Self> {
cx.global::<GlobalDapStore>().0.clone()
}
pub fn new(cx: &mut ModelContext<Self>) -> Self {
cx.on_app_quit(Self::shutdown_clients).detach();

View File

@@ -640,8 +640,6 @@ impl Project {
env: Option<HashMap<String, String>>,
cx: &mut AppContext,
) -> Model<Self> {
let dap_store = DapStore::global(cx);
cx.new_model(|cx: &mut ModelContext<Self>| {
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<dyn Fs>,
cx: &mut AppContext,
) -> Model<Self> {
let dap_store = DapStore::global(cx);
cx.new_model(|cx: &mut ModelContext<Self>| {
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(