From a1eef6829f087195642d63bef116cfc18510bde0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sat, 26 Aug 2023 22:56:35 +0200 Subject: [PATCH] Correctly shutdown the server on ``shutdown` request --- vhdl_ls/src/stdio_server.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/vhdl_ls/src/stdio_server.rs b/vhdl_ls/src/stdio_server.rs index ce74ff1a..ca97996e 100644 --- a/vhdl_ls/src/stdio_server.rs +++ b/vhdl_ls/src/stdio_server.rs @@ -86,7 +86,18 @@ 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(); + } else { + self.handle_request(&mut server, request) + } + } + Err(err) => panic!("{err:?}"), + } + } lsp_server::Message::Notification(notification) => { self.handle_notification(&mut server, notification); } @@ -195,14 +206,6 @@ impl ConnectionRpcChannel { } Err(request) => request, }; - let request = match extract::(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(