diff options
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 0f8ef10b9..145f7bf65 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -46,7 +46,6 @@ enum Task { | |||
46 | const THREADPOOL_SIZE: usize = 8; | 46 | const THREADPOOL_SIZE: usize = 8; |
47 | 47 | ||
48 | pub fn main_loop( | 48 | pub fn main_loop( |
49 | internal_mode: bool, | ||
50 | ws_root: PathBuf, | 49 | ws_root: PathBuf, |
51 | supports_decorations: bool, | 50 | supports_decorations: bool, |
52 | msg_receiver: &Receiver<RawMessage>, | 51 | msg_receiver: &Receiver<RawMessage>, |
@@ -63,11 +62,12 @@ pub fn main_loop( | |||
63 | Ok(ws) => vec![ws], | 62 | Ok(ws) => vec![ws], |
64 | Err(e) => { | 63 | Err(e) => { |
65 | log::error!("loading workspace failed: {}", e); | 64 | log::error!("loading workspace failed: {}", e); |
66 | let msg = RawNotification::new::<req::ShowMessage>(&req::ShowMessageParams { | 65 | |
67 | typ: req::MessageType::Error, | 66 | feedback( |
68 | message: format!("rust-analyzer failed to load workspace: {}", e), | 67 | req::MessageType::Error, |
69 | }); | 68 | format!("rust-analyzer failed to load workspace: {}", e), |
70 | msg_sender.send(msg.into()).unwrap(); | 69 | msg_sender, |
70 | ); | ||
71 | Vec::new() | 71 | Vec::new() |
72 | } | 72 | } |
73 | } | 73 | } |
@@ -80,7 +80,6 @@ pub fn main_loop( | |||
80 | let mut pending_requests = FxHashSet::default(); | 80 | let mut pending_requests = FxHashSet::default(); |
81 | let mut subs = Subscriptions::new(); | 81 | let mut subs = Subscriptions::new(); |
82 | let main_res = main_loop_inner( | 82 | let main_res = main_loop_inner( |
83 | internal_mode, | ||
84 | supports_decorations, | 83 | supports_decorations, |
85 | &pool, | 84 | &pool, |
86 | msg_sender, | 85 | msg_sender, |
@@ -148,7 +147,6 @@ impl fmt::Debug for Event { | |||
148 | } | 147 | } |
149 | 148 | ||
150 | fn main_loop_inner( | 149 | fn main_loop_inner( |
151 | internal_mode: bool, | ||
152 | supports_decorations: bool, | 150 | supports_decorations: bool, |
153 | pool: &ThreadPool, | 151 | pool: &ThreadPool, |
154 | msg_sender: &Sender<RawMessage>, | 152 | msg_sender: &Sender<RawMessage>, |
@@ -163,6 +161,7 @@ fn main_loop_inner( | |||
163 | // time to always have a thread ready to react to input. | 161 | // time to always have a thread ready to react to input. |
164 | let mut in_flight_libraries = 0; | 162 | let mut in_flight_libraries = 0; |
165 | let mut pending_libraries = Vec::new(); | 163 | let mut pending_libraries = Vec::new(); |
164 | let mut send_workspace_notification = true; | ||
166 | 165 | ||
167 | let (libdata_sender, libdata_receiver) = unbounded(); | 166 | let (libdata_sender, libdata_receiver) = unbounded(); |
168 | loop { | 167 | loop { |
@@ -190,7 +189,6 @@ fn main_loop_inner( | |||
190 | state_changed = true; | 189 | state_changed = true; |
191 | } | 190 | } |
192 | Event::Lib(lib) => { | 191 | Event::Lib(lib) => { |
193 | feedback(internal_mode, "library loaded", msg_sender); | ||
194 | state.add_lib(lib); | 192 | state.add_lib(lib); |
195 | in_flight_libraries -= 1; | 193 | in_flight_libraries -= 1; |
196 | } | 194 | } |
@@ -244,8 +242,14 @@ fn main_loop_inner( | |||
244 | }); | 242 | }); |
245 | } | 243 | } |
246 | 244 | ||
247 | if state.roots_to_scan == 0 && pending_libraries.is_empty() && in_flight_libraries == 0 { | 245 | if send_workspace_notification |
248 | feedback(internal_mode, "workspace loaded", msg_sender); | 246 | && state.roots_to_scan == 0 |
247 | && pending_libraries.is_empty() | ||
248 | && in_flight_libraries == 0 | ||
249 | { | ||
250 | feedback(req::MessageType::Info, "workspace loaded", msg_sender); | ||
251 | // Only send the notification first time | ||
252 | send_workspace_notification = false; | ||
249 | } | 253 | } |
250 | 254 | ||
251 | if state_changed { | 255 | if state_changed { |
@@ -501,11 +505,12 @@ fn update_file_notifications_on_threadpool( | |||
501 | }); | 505 | }); |
502 | } | 506 | } |
503 | 507 | ||
504 | fn feedback(intrnal_mode: bool, msg: &str, sender: &Sender<RawMessage>) { | 508 | fn feedback<M: Into<String>>(typ: req::MessageType, msg: M, sender: &Sender<RawMessage>) { |
505 | if !intrnal_mode { | 509 | let not = RawNotification::new::<req::ShowMessage>(&req::ShowMessageParams { |
506 | return; | 510 | typ, |
507 | } | 511 | message: msg.into(), |
508 | let not = RawNotification::new::<req::InternalFeedback>(&msg.to_string()); | 512 | }); |
513 | |||
509 | sender.send(not.into()).unwrap(); | 514 | sender.send(not.into()).unwrap(); |
510 | } | 515 | } |
511 | 516 | ||