Skip to content

Commit

Permalink
Correctly shutdown the server on `shutdown request
Browse files Browse the repository at this point in the history
  • Loading branch information
Rutherther committed Sep 9, 2023
1 parent 6681f48 commit 8d3da8c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions vhdl_ls/src/stdio_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,19 @@ impl ConnectionRpcChannel {
while let Ok(message) = self.connection.receiver.recv() {
trace!("Received message: {:?}", message);
match message {
lsp_server::Message::Request(request) => self.handle_request(&mut server, request),
lsp_server::Message::Request(request) => {
match self.connection.handle_shutdown(&request) {
Ok(shutdown) => {
if shutdown {
server.shutdown_server();
break;
}
},
Err(err) => panic!("{err:?}")
}

self.handle_request(&mut server, request)
},
lsp_server::Message::Notification(notification) => {
self.handle_notification(&mut server, notification);
}
Expand Down Expand Up @@ -195,14 +207,6 @@ impl ConnectionRpcChannel {
}
Err(request) => request,
};
let request = match extract::<request::Shutdown>(request) {
Ok((id, _params)) => {
server.shutdown_server();
self.send_response(lsp_server::Response::new_ok(id, ()));
return;
}
Err(request) => request,
};

debug!("Unhandled request: {:?}", request);
self.send_response(lsp_server::Response::new_err(
Expand Down

0 comments on commit 8d3da8c

Please sign in to comment.