From c2aad859b12e01c7724f16ddf957e6db2b3c8a60 Mon Sep 17 00:00:00 2001 From: wojciechkepka Date: Sat, 19 Jun 2021 04:56:50 +0200 Subject: Handle language server shutdown with timeout --- helix-lsp/src/client.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'helix-lsp/src/client.rs') diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 245eb854..101d2f9b 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -272,6 +272,21 @@ impl Client { self.notify::(()) } + /// Tries to shut down the language server but returns + /// early if server responds with an error. + pub async fn shutdown_and_exit(&self) -> Result<()> { + self.shutdown().await?; + self.exit().await + } + + /// Forcefully shuts down the language server ignoring any errors. + pub async fn force_shutdown(&self) -> Result<()> { + if let Err(e) = self.shutdown().await { + log::warn!("language server failed to terminate gracefully - {}", e); + } + self.exit().await + } + // ------------------------------------------------------------------------------------------- // Text document // ------------------------------------------------------------------------------------------- -- cgit v1.2.3-70-g09d2