summaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-01-06 08:48:14 +0000
committerBlaž Hrastnik2021-01-06 08:48:14 +0000
commit941c34a7fc86e613b41887174c699be52ab202a8 (patch)
tree36bdaf9f2ac4ff19e01ba4588639785e5093999b /helix-lsp
parentb2800489dedb44cf030cd425d737ea14491518aa (diff)
lsp: Move timeouts into client.request
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/Cargo.toml1
-rw-r--r--helix-lsp/src/client.rs9
2 files changed, 9 insertions, 1 deletions
diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml
index 18aa90d0..caf9287a 100644
--- a/helix-lsp/Cargo.toml
+++ b/helix-lsp/Cargo.toml
@@ -13,6 +13,7 @@ once_cell = "1.4"
lsp-types = { version = "0.86", features = ["proposed"] }
smol = "1.2"
+smol-timeout = "0.6"
url = "2"
pathdiff = "0.2"
shellexpand = "2.0"
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index 207e2970..e3f72a56 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -114,7 +114,14 @@ impl Client {
.await
.map_err(|e| Error::Other(e.into()))?;
- let response = rx.recv().await.map_err(|e| Error::Other(e.into()))??;
+ use smol_timeout::TimeoutExt;
+ use std::time::Duration;
+
+ let response = match rx.recv().timeout(Duration::from_secs(2)).await {
+ Some(response) => response,
+ None => return Err(Error::Timeout),
+ }
+ .map_err(|e| Error::Other(e.into()))??;
let response = serde_json::from_value(response)?;