This commit is contained in:
Piotr Osiewicz
2025-02-18 02:09:23 +01:00
parent afaaf24455
commit a8f59b8a1d
3 changed files with 21 additions and 31 deletions

View File

@@ -113,8 +113,7 @@ impl LogStore {
})
.detach_and_log_err(cx);
let (adapter_log_tx, mut adapter_log_rx) =
unbounded::<(SessionId, IoKind, String)>();
let (adapter_log_tx, mut adapter_log_rx) = unbounded::<(SessionId, IoKind, String)>();
cx.spawn(|this, mut cx| async move {
while let Some((client_id, io_kind, message)) = adapter_log_rx.next().await {
if let Some(this) = this.upgrade() {
@@ -170,7 +169,7 @@ impl LogStore {
let client = project.update(cx, |project, cx| {
project.dap_store().update(cx, |store, cx| {
store
.client_by_id(client_id)
.session_by_id(client_id)
.and_then(|client| Some(client))
})
});
@@ -189,10 +188,7 @@ impl LogStore {
);
}
fn get_debug_adapter_state(
&mut self,
id: SessionId,
) -> Option<&mut DebugAdapterState> {
fn get_debug_adapter_state(&mut self, id: SessionId) -> Option<&mut DebugAdapterState> {
self.debug_clients.get_mut(&id)
}
@@ -328,17 +324,11 @@ impl LogStore {
cx.notify();
}
fn log_messages_for_client(
&mut self,
client_id: SessionId,
) -> Option<&mut VecDeque<String>> {
fn log_messages_for_client(&mut self, client_id: SessionId) -> Option<&mut VecDeque<String>> {
Some(&mut self.debug_clients.get_mut(&client_id)?.log_messages)
}
fn rpc_messages_for_client(
&mut self,
client_id: SessionId,
) -> Option<&mut VecDeque<String>> {
fn rpc_messages_for_client(&mut self, client_id: SessionId) -> Option<&mut VecDeque<String>> {
Some(
&mut self
.debug_clients
@@ -568,7 +558,7 @@ impl DapLogView {
.read(cx)
.dap_store()
.read(cx)
.clients()
.sessions()
.filter_map(|client| {
let client = client.read(cx).adapter_client()?;
Some(DapMenuItem {

View File

@@ -128,7 +128,7 @@ impl PickerDelegate for AttachModalDelegate {
} else {
let Some(client) = this.delegate.dap_store.update(cx, |store, cx| {
store
.client_by_id(&this.delegate.client_id)
.session_by_id(&this.delegate.client_id)
.and_then(|client| client.read(cx).adapter_client())
}) else {
return Vec::new();

View File

@@ -353,7 +353,7 @@ impl DapStore {
}
}
pub fn client_by_id(
pub fn session_by_id(
&self,
session_id: impl Borrow<SessionId>,
) -> Option<Entity<session::Session>> {
@@ -362,7 +362,7 @@ impl DapStore {
client
}
pub fn clients(&self) -> impl Iterator<Item = &Entity<Session>> {
pub fn sessions(&self) -> impl Iterator<Item = &Entity<Session>> {
self.sessions.values()
}
@@ -383,7 +383,7 @@ impl DapStore {
capabilities: &Capabilities,
cx: &mut Context<Self>,
) {
if let Some(client) = self.client_by_id(session_id) {
if let Some(client) = self.session_by_id(session_id) {
client.update(cx, |this, cx| {
this.capabilities = this.capabilities.merge(capabilities.clone());
});
@@ -450,7 +450,7 @@ impl DapStore {
let session_id = SessionId::from_proto(envelope.payload.session_id);
this.update(&mut cx, |this, cx| {
if let Some(client) = this.client_by_id(&session_id) {
if let Some(client) = this.session_by_id(&session_id) {
client.update(cx, |client, cx| {
client.set_ignore_breakpoints(envelope.payload.ignore)
});
@@ -466,7 +466,7 @@ impl DapStore {
ignore: bool,
cx: &mut Context<Self>,
) {
if let Some(session) = self.client_by_id(session_id) {
if let Some(session) = self.session_by_id(session_id) {
session.update(cx, |session, _| {
session.set_ignore_breakpoints(ignore);
});
@@ -474,13 +474,13 @@ impl DapStore {
}
pub fn ignore_breakpoints(&self, session_id: &SessionId, cx: &App) -> bool {
self.client_by_id(session_id)
self.session_by_id(session_id)
.map(|client| client.read(cx).breakpoints_enabled())
.unwrap_or_default()
}
pub fn toggle_ignore_breakpoints(&mut self, session_id: &SessionId, cx: &mut Context<Self>) {
if let Some(client) = self.client_by_id(session_id) {
if let Some(client) = self.session_by_id(session_id) {
client.update(cx, |client, _| {
client.set_ignore_breakpoints(!client.breakpoints_enabled());
});
@@ -659,7 +659,7 @@ impl DapStore {
cx: &mut Context<Self>,
) -> Task<Result<()>> {
let Some(client) = self
.client_by_id(session_id)
.session_by_id(session_id)
.and_then(|client| client.read(cx).adapter_client())
else {
return Task::ready(Err(anyhow!("Could not find client: {:?}", session_id)));
@@ -768,7 +768,7 @@ impl DapStore {
cx: &mut Context<Self>,
) -> Task<Result<()>> {
let Some(client) = self
.client_by_id(session_id)
.session_by_id(session_id)
.and_then(|client| client.read(cx).adapter_client())
else {
return Task::ready(Err(anyhow!(
@@ -800,7 +800,7 @@ impl DapStore {
cx: &mut Context<Self>,
) -> Task<Result<EvaluateResponse>> {
let Some(client) = self
.client_by_id(session_id)
.session_by_id(session_id)
.and_then(|client| client.read(cx).adapter_client())
else {
return Task::ready(Err(anyhow!("Could not find client: {:?}", session_id)));
@@ -830,7 +830,7 @@ impl DapStore {
cx: &mut Context<Self>,
) -> Task<Result<Vec<CompletionItem>>> {
let Some(client) = self
.client_by_id(session_id)
.session_by_id(session_id)
.and_then(|client| client.read(cx).adapter_client())
else {
return Task::ready(Err(anyhow!("Could not find client: {:?}", session_id)));
@@ -861,7 +861,7 @@ impl DapStore {
cx: &mut Context<Self>,
) -> Task<Result<()>> {
let Some(client) = self
.client_by_id(session_id)
.session_by_id(session_id)
.and_then(|client| client.read(cx).adapter_client())
else {
return Task::ready(Err(anyhow!("Could not find client: {:?}", session_id)));
@@ -1035,7 +1035,7 @@ impl DapStore {
this.update(&mut cx, |dap_store, cx| {
let session_id = SessionId::from_proto(envelope.payload.session_id);
dap_store.client_by_id(session_id).map(|state| {
dap_store.session_by_id(session_id).map(|state| {
state.update(cx, |state, cx| {
state.shutdown(cx);
})
@@ -1093,7 +1093,7 @@ impl DapStore {
cx: &App,
) -> Task<Result<()>> {
let Some(client) = self
.client_by_id(session_id)
.session_by_id(session_id)
.and_then(|client| client.read(cx).adapter_client())
else {
return Task::ready(Err(anyhow!("Could not find client: {:?}", session_id)));