mirror of
https://github.com/helix-editor/helix
synced 2024-05-08 11:56:04 +02:00
Fix unwrap bug in DAP (#6786)
This commit is contained in:
parent
1b016a89d5
commit
8839eb0af4
|
@ -62,12 +62,10 @@ pub async fn process(
|
||||||
if command.is_empty() {
|
if command.is_empty() {
|
||||||
return Result::Err(Error::Other(anyhow!("Command not provided")));
|
return Result::Err(Error::Other(anyhow!("Command not provided")));
|
||||||
}
|
}
|
||||||
if transport == "tcp" && port_arg.is_some() {
|
match (transport, port_arg) {
|
||||||
Self::tcp_process(command, args, port_arg.unwrap(), id).await
|
("tcp", Some(port_arg)) => Self::tcp_process(command, args, port_arg, id).await,
|
||||||
} else if transport == "stdio" {
|
("stdio", _) => Self::stdio(command, args, id),
|
||||||
Self::stdio(command, args, id)
|
_ => Result::Err(Error::Other(anyhow!("Incorrect transport {}", transport))),
|
||||||
} else {
|
|
||||||
Result::Err(Error::Other(anyhow!("Incorrect transport {}", transport)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,38 +230,48 @@ async fn process_server_message(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn recv(
|
async fn recv_inner(
|
||||||
transport: Arc<Self>,
|
transport: Arc<Self>,
|
||||||
mut server_stdout: Box<dyn AsyncBufRead + Unpin + Send>,
|
mut server_stdout: Box<dyn AsyncBufRead + Unpin + Send>,
|
||||||
client_tx: UnboundedSender<Payload>,
|
client_tx: UnboundedSender<Payload>,
|
||||||
) {
|
) -> Result<()> {
|
||||||
let mut recv_buffer = String::new();
|
let mut recv_buffer = String::new();
|
||||||
loop {
|
loop {
|
||||||
match Self::recv_server_message(&mut server_stdout, &mut recv_buffer).await {
|
let msg = Self::recv_server_message(&mut server_stdout, &mut recv_buffer).await?;
|
||||||
Ok(msg) => {
|
transport.process_server_message(&client_tx, msg).await?;
|
||||||
transport
|
|
||||||
.process_server_message(&client_tx, msg)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
error!("err: <- {:?}", err);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn recv(
|
||||||
|
transport: Arc<Self>,
|
||||||
|
server_stdout: Box<dyn AsyncBufRead + Unpin + Send>,
|
||||||
|
client_tx: UnboundedSender<Payload>,
|
||||||
|
) {
|
||||||
|
if let Err(err) = Self::recv_inner(transport, server_stdout, client_tx).await {
|
||||||
|
error!("err: <- {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn send_inner(
|
||||||
|
transport: Arc<Self>,
|
||||||
|
mut server_stdin: Box<dyn AsyncWrite + Unpin + Send>,
|
||||||
|
mut client_rx: UnboundedReceiver<Payload>,
|
||||||
|
) -> Result<()> {
|
||||||
|
while let Some(payload) = client_rx.recv().await {
|
||||||
|
transport
|
||||||
|
.send_payload_to_server(&mut server_stdin, payload)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn send(
|
async fn send(
|
||||||
transport: Arc<Self>,
|
transport: Arc<Self>,
|
||||||
mut server_stdin: Box<dyn AsyncWrite + Unpin + Send>,
|
server_stdin: Box<dyn AsyncWrite + Unpin + Send>,
|
||||||
mut client_rx: UnboundedReceiver<Payload>,
|
client_rx: UnboundedReceiver<Payload>,
|
||||||
) {
|
) {
|
||||||
while let Some(payload) = client_rx.recv().await {
|
if let Err(err) = Self::send_inner(transport, server_stdin, client_rx).await {
|
||||||
transport
|
error!("err: <- {:?}", err);
|
||||||
.send_payload_to_server(&mut server_stdin, payload)
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -321,6 +321,7 @@ pub async fn handle_debugger_message(&mut self, payload: helix_dap::Payload) ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
self.debugger = None;
|
||||||
self.set_status(
|
self.set_status(
|
||||||
"Terminated debugging session and disconnected debugger.",
|
"Terminated debugging session and disconnected debugger.",
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue