Skip to content

Commit

Permalink
feat: allow lsp calls with a custom timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
yo-main committed Oct 22, 2023
1 parent 62dfaa8 commit 08f8f0a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions helix-lsp/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,22 @@ impl Client {
&self,
params: R::Params,
) -> impl Future<Output = Result<Value>>
where
R::Params: serde::Serialize,
{
self.call_with_timeout::<R>(params, self.req_timeout)
}

fn call_with_timeout<R: lsp::request::Request>(
&self,
params: R::Params,
timeout_secs: u64,
) -> impl Future<Output = Result<Value>>
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;
Expand Down Expand Up @@ -727,7 +737,10 @@ impl Client {
old_uri: old_uri.to_string(),
new_uri: new_uri.to_string(),
}];
let request = self.call::<lsp::request::WillRenameFiles>(lsp::RenameFilesParams { files });
let request = self.call_with_timeout::<lsp::request::WillRenameFiles>(
lsp::RenameFilesParams { files },
5,
);

Some(async move {
let json = request.await?;
Expand Down

0 comments on commit 08f8f0a

Please sign in to comment.