diff options
Diffstat (limited to 'helix-dap/src/transport.rs')
-rw-r--r-- | helix-dap/src/transport.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/helix-dap/src/transport.rs b/helix-dap/src/transport.rs index afb7694d..a20dfbe1 100644 --- a/helix-dap/src/transport.rs +++ b/helix-dap/src/transport.rs @@ -53,6 +53,7 @@ impl Transport { pub fn start( server_stdout: Box<dyn AsyncBufRead + Unpin + Send>, server_stdin: Box<dyn AsyncWrite + Unpin + Send>, + server_stderr: Option<Box<dyn AsyncBufRead + Unpin + Send>>, id: usize, ) -> (UnboundedReceiver<Payload>, UnboundedSender<Request>) { let (client_tx, rx) = unbounded_channel(); @@ -67,6 +68,9 @@ impl Transport { tokio::spawn(Self::recv(transport.clone(), server_stdout, client_tx)); tokio::spawn(Self::send(transport, server_stdin, client_rx)); + if let Some(stderr) = server_stderr { + tokio::spawn(Self::err(stderr)); + } (rx, tx) } @@ -117,6 +121,17 @@ impl Transport { Ok(output?) } + async fn recv_server_error( + err: &mut (impl AsyncBufRead + Unpin + Send), + buffer: &mut String, + ) -> Result<()> { + buffer.truncate(0); + err.read_line(buffer).await?; + error!("err <- {}", buffer); + + Ok(()) + } + async fn send_payload_to_server( &self, server_stdin: &mut Box<dyn AsyncWrite + Unpin + Send>, @@ -243,4 +258,17 @@ impl Transport { .unwrap() } } + + async fn err(mut server_stderr: Box<dyn AsyncBufRead + Unpin + Send>) { + let mut recv_buffer = String::new(); + loop { + match Self::recv_server_error(&mut server_stderr, &mut recv_buffer).await { + Ok(_) => {} + Err(err) => { + error!("err: <- {:?}", err); + break; + } + } + } + } } |