From 41d4c486bbd9518a66644145d7d7de83e3a8bad5 Mon Sep 17 00:00:00 2001 From: Yomain Date: Sun, 22 Oct 2023 18:20:51 +0200 Subject: [PATCH] feat: allow lsp calls with a custom timeout --- helix-lsp/src/client.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 00c04817ffbec..e6e1f8a033010 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -401,12 +401,22 @@ impl Client { &self, params: R::Params, ) -> impl Future> + where + R::Params: serde::Serialize, + { + self.call_with_timeout::(params, self.req_timeout) + } + + fn call_with_timeout( + &self, + params: R::Params, + timeout_secs: u64, + ) -> impl Future> where R::Params: serde::Serialize, { let server_tx = self.server_tx.clone(); let id = self.next_request_id(); - let timeout_secs = self.req_timeout; async move { use std::time::Duration; @@ -727,7 +737,10 @@ impl Client { old_uri: old_uri.to_string(), new_uri: new_uri.to_string(), }]; - let request = self.call::(lsp::RenameFilesParams { files }); + let request = self.call_with_timeout::( + lsp::RenameFilesParams { files }, + 5, + ); Some(async move { let json = request.await?;