aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/gen_lsp_server/src/lib.rs2
-rw-r--r--crates/gen_lsp_server/src/stdio.rs18
-rw-r--r--crates/ra_lsp_server/src/main.rs2
3 files changed, 17 insertions, 5 deletions
diff --git a/crates/gen_lsp_server/src/lib.rs b/crates/gen_lsp_server/src/lib.rs
index 86b72f663..edbdda6c8 100644
--- a/crates/gen_lsp_server/src/lib.rs
+++ b/crates/gen_lsp_server/src/lib.rs
@@ -22,7 +22,7 @@
22//! sender, 22//! sender,
23//! main_loop, 23//! main_loop,
24//! )?; 24//! )?;
25//! io_threads.exit()?; 25//! io_threads.join()?;
26//! Ok(()) 26//! Ok(())
27//! } 27//! }
28//! 28//!
diff --git a/crates/gen_lsp_server/src/stdio.rs b/crates/gen_lsp_server/src/stdio.rs
index c5fe5b83a..5edfbc39c 100644
--- a/crates/gen_lsp_server/src/stdio.rs
+++ b/crates/gen_lsp_server/src/stdio.rs
@@ -5,6 +5,7 @@ use std::{
5 5
6use crossbeam_channel::{bounded, Receiver, Sender}; 6use crossbeam_channel::{bounded, Receiver, Sender};
7use failure::bail; 7use failure::bail;
8use lsp_types::notification::Exit;
8 9
9use crate::{RawMessage, Result}; 10use crate::{RawMessage, Result};
10 11
@@ -21,9 +22,18 @@ pub fn stdio_transport() -> (Receiver<RawMessage>, Sender<RawMessage>, Threads)
21 let stdin = stdin(); 22 let stdin = stdin();
22 let mut stdin = stdin.lock(); 23 let mut stdin = stdin.lock();
23 while let Some(msg) = RawMessage::read(&mut stdin)? { 24 while let Some(msg) = RawMessage::read(&mut stdin)? {
25 let is_exit = match &msg {
26 RawMessage::Notification(n) => n.is::<Exit>(),
27 _ => false,
28 };
29
24 if let Err(_) = reader_sender.send(msg) { 30 if let Err(_) = reader_sender.send(msg) {
25 break; 31 break;
26 } 32 }
33
34 if is_exit {
35 break;
36 }
27 } 37 }
28 Ok(()) 38 Ok(())
29 }); 39 });
@@ -37,9 +47,11 @@ pub struct Threads {
37} 47}
38 48
39impl Threads { 49impl Threads {
40 pub fn exit(self) -> Result<()> { 50 pub fn join(self) -> Result<()> {
41 // We can't rely on stdin being closed 51 match self.reader.join() {
42 drop(self.reader); 52 Ok(r) => r?,
53 Err(_) => bail!("reader panicked"),
54 }
43 match self.writer.join() { 55 match self.writer.join() {
44 Ok(r) => r, 56 Ok(r) => r,
45 Err(_) => bail!("writer panicked"), 57 Err(_) => bail!("writer panicked"),
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index 6b1274a3b..b0b70df5c 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -54,7 +54,7 @@ fn main_inner() -> Result<()> {
54 ra_lsp_server::main_loop(workspace_roots, opts, r, s) 54 ra_lsp_server::main_loop(workspace_roots, opts, r, s)
55 })?; 55 })?;
56 log::info!("shutting down IO..."); 56 log::info!("shutting down IO...");
57 threads.exit()?; 57 threads.join()?;
58 log::info!("... IO is down"); 58 log::info!("... IO is down");
59 Ok(()) 59 Ok(())
60} 60}