Skip to content

Commit

Permalink
Pass http client to dap store
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony-Eid committed Sep 24, 2024
1 parent 3b3ac85 commit 4010095
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion crates/project/src/dap_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use dap::{
VariablesArguments,
};
use gpui::{EventEmitter, ModelContext, Task};
use http_client::HttpClient;
use language::{Buffer, BufferSnapshot};
use serde_json::Value;
use settings::WorktreeId;
Expand Down Expand Up @@ -54,19 +55,21 @@ pub struct DapStore {
clients: HashMap<DebugAdapterClientId, DebugAdapterClientState>,
breakpoints: BTreeMap<ProjectPath, HashSet<Breakpoint>>,
capabilities: HashMap<DebugAdapterClientId, Capabilities>,
_http_client: Option<Arc<dyn HttpClient>>,
}

impl EventEmitter<DapStoreEvent> for DapStore {}

impl DapStore {
pub fn new(cx: &mut ModelContext<Self>) -> Self {
pub fn new(http_client: Option<Arc<dyn HttpClient>>, cx: &mut ModelContext<Self>) -> Self {
cx.on_app_quit(Self::shutdown_clients).detach();

Self {
clients: Default::default(),
capabilities: HashMap::default(),
breakpoints: Default::default(),
next_client_id: Default::default(),
_http_client: http_client,
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/project/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ impl Project {
cx.subscribe(&worktree_store, Self::on_worktree_store_event)
.detach();

let dap_store = cx.new_model(DapStore::new);
let dap_store = cx.new_model(|cx| DapStore::new(Some(client.http_client()), cx));

let buffer_store = cx.new_model(|cx| {
BufferStore::new(worktree_store.clone(), None, dap_store.clone(), cx)
Expand Down Expand Up @@ -757,7 +757,7 @@ impl Project {
cx.subscribe(&worktree_store, Self::on_worktree_store_event)
.detach();

let dap_store = cx.new_model(DapStore::new);
let dap_store = cx.new_model(|cx| DapStore::new(Some(client.http_client()), cx));

let buffer_store = cx.new_model(|cx| {
BufferStore::new(worktree_store.clone(), None, dap_store.clone(), cx)
Expand Down Expand Up @@ -916,7 +916,7 @@ impl Project {
store
})?;

let dap_store = cx.new_model(DapStore::new)?;
let dap_store = cx.new_model(|cx| DapStore::new(Some(client.http_client()), cx))?;

let buffer_store = cx.new_model(|cx| {
BufferStore::new(
Expand Down
2 changes: 1 addition & 1 deletion crates/remote_server/src/headless_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl HeadlessProject {
store
});

let dap_store = cx.new_model(DapStore::new);
let dap_store = cx.new_model(|cx| DapStore::new(None, cx));
let buffer_store = cx.new_model(|cx| {
let mut buffer_store = BufferStore::new(
worktree_store.clone(),
Expand Down

0 comments on commit 4010095

Please sign in to comment.