Debug adapters log to console (#29957)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2025-05-06 11:21:34 +01:00 committed by GitHub
parent de554589a8
commit 68793c0ac2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 268 additions and 330 deletions

View file

@ -170,7 +170,7 @@ impl LocalMode {
} else {
DebugAdapterClient::start(session_id, binary.clone(), message_handler, cx.clone())
.await
.with_context(|| "Failed to start communication with debug adapter")?
.with_context(|| format!("Failed to start {:?}", &binary.command))?
},
);
@ -815,6 +815,33 @@ impl Session {
self.is_session_terminated
}
pub fn console_output(&mut self, cx: &mut Context<Self>) -> mpsc::UnboundedSender<String> {
let (tx, mut rx) = mpsc::unbounded();
cx.spawn(async move |this, cx| {
while let Some(output) = rx.next().await {
this.update(cx, |this, _| {
this.output_token.0 += 1;
this.output.push_back(dap::OutputEvent {
category: None,
output,
group: None,
variables_reference: None,
source: None,
line: None,
column: None,
data: None,
location_reference: None,
});
})?;
}
anyhow::Ok(())
})
.detach();
return tx;
}
pub fn is_local(&self) -> bool {
matches!(self.mode, Mode::Running(_))
}