aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorVille Penttinen <[email protected]>2019-02-27 10:49:04 +0000
committerVille Penttinen <[email protected]>2019-02-27 10:49:04 +0000
commit33cebe172459d1ae46556c7808411f1f539aa7cf (patch)
tree86c9b76381ad0731878e684fab5a46a983a70dcf /crates
parent4248b39993e2446c66f732ae9e45fb2f564099f5 (diff)
Work around for issue in vscode reporting a failure in request
vscode would report "A request has failed" when it got "Content modified" message and this would cause a pop-up to appear. This works around the issue by returning an "empty" response that vscode can ignore.
Diffstat (limited to 'crates')
-rw-r--r--crates/gen_lsp_server/src/msg.rs5
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs16
2 files changed, 16 insertions, 5 deletions
diff --git a/crates/gen_lsp_server/src/msg.rs b/crates/gen_lsp_server/src/msg.rs
index 02c7a1858..dfd9eeeb4 100644
--- a/crates/gen_lsp_server/src/msg.rs
+++ b/crates/gen_lsp_server/src/msg.rs
@@ -120,6 +120,11 @@ impl RawResponse {
120 let error = RawResponseError { code, message, data: None }; 120 let error = RawResponseError { code, message, data: None };
121 RawResponse { id, result: None, error: Some(error) } 121 RawResponse { id, result: None, error: Some(error) }
122 } 122 }
123 /// Returns an "empty" RawResponse
124 /// Empty response still has a value `()` in its `result` field.
125 pub fn empty(id: u64) -> RawResponse {
126 RawResponse { id, result: Some(to_value(&()).unwrap()), error: None }
127 }
123} 128}
124 129
125impl RawNotification { 130impl RawNotification {
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 06443bb76..1baeff266 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -416,11 +416,17 @@ impl<'a> PoolDispatcher<'a> {
416 } 416 }
417 Err(e) => { 417 Err(e) => {
418 if is_canceled(&e) { 418 if is_canceled(&e) {
419 RawResponse::err( 419 // FIXME: When https://github.com/Microsoft/vscode-languageserver-node/issues/457
420 id, 420 // gets fixed, we can return the proper response.
421 ErrorCode::ContentModified as i32, 421 // This works around the issue where "content modified" error would continuously
422 "content modified".to_string(), 422 // show an message pop-up in VsCode
423 ) 423 // RawResponse::err(
424 // id,
425 // ErrorCode::ContentModified as i32,
426 // "content modified".to_string(),
427 // )
428 RawResponse::empty(id)
429
424 } else { 430 } else {
425 RawResponse::err( 431 RawResponse::err(
426 id, 432 id,