aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop.rs')
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs26
1 files changed, 12 insertions, 14 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index a51299851..06443bb76 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -54,19 +54,20 @@ pub fn main_loop(
54) -> Result<()> { 54) -> Result<()> {
55 let pool = ThreadPool::new(THREADPOOL_SIZE); 55 let pool = ThreadPool::new(THREADPOOL_SIZE);
56 let (task_sender, task_receiver) = unbounded::<Task>(); 56 let (task_sender, task_receiver) = unbounded::<Task>();
57 let (ws_worker, ws_watcher) = workspace_loader();
58 57
59 ws_worker.send(ws_root.clone()).unwrap();
60 // FIXME: support dynamic workspace loading. 58 // FIXME: support dynamic workspace loading.
61 let workspaces = match ws_worker.recv().unwrap() { 59 let workspaces = {
62 Ok(ws) => vec![ws], 60 let ws_worker = workspace_loader();
63 Err(e) => { 61 ws_worker.sender().send(ws_root.clone()).unwrap();
64 log::error!("loading workspace failed: {}", e); 62 match ws_worker.receiver().recv().unwrap() {
65 Vec::new() 63 Ok(ws) => vec![ws],
64 Err(e) => {
65 log::error!("loading workspace failed: {}", e);
66 Vec::new()
67 }
66 } 68 }
67 }; 69 };
68 ws_worker.shutdown(); 70
69 ws_watcher.shutdown().map_err(|_| format_err!("ws watcher died"))?;
70 let mut state = ServerWorldState::new(ws_root.clone(), workspaces); 71 let mut state = ServerWorldState::new(ws_root.clone(), workspaces);
71 72
72 log::info!("server initialized, serving requests"); 73 log::info!("server initialized, serving requests");
@@ -94,12 +95,9 @@ pub fn main_loop(
94 log::info!("...threadpool has finished"); 95 log::info!("...threadpool has finished");
95 96
96 let vfs = Arc::try_unwrap(state.vfs).expect("all snapshots should be dead"); 97 let vfs = Arc::try_unwrap(state.vfs).expect("all snapshots should be dead");
97 let vfs_res = vfs.into_inner().shutdown(); 98 drop(vfs);
98 99
99 main_res?; 100 main_res
100 vfs_res.map_err(|_| format_err!("fs watcher died"))?;
101
102 Ok(())
103} 101}
104 102
105enum Event { 103enum Event {