diff options
Diffstat (limited to 'crates/ra_cargo_watch/src')
-rw-r--r-- | crates/ra_cargo_watch/src/lib.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/crates/ra_cargo_watch/src/lib.rs b/crates/ra_cargo_watch/src/lib.rs index bbe634603..9af9c347d 100644 --- a/crates/ra_cargo_watch/src/lib.rs +++ b/crates/ra_cargo_watch/src/lib.rs | |||
@@ -9,6 +9,7 @@ use lsp_types::{ | |||
9 | }; | 9 | }; |
10 | use std::{ | 10 | use std::{ |
11 | collections::HashMap, | 11 | collections::HashMap, |
12 | io::BufReader, | ||
12 | path::PathBuf, | 13 | path::PathBuf, |
13 | process::{Command, Stdio}, | 14 | process::{Command, Stdio}, |
14 | sync::Arc, | 15 | sync::Arc, |
@@ -215,8 +216,10 @@ impl CheckWatcherThread { | |||
215 | self.last_update_req.take(); | 216 | self.last_update_req.take(); |
216 | task_send.send(CheckTask::ClearDiagnostics).unwrap(); | 217 | task_send.send(CheckTask::ClearDiagnostics).unwrap(); |
217 | 218 | ||
218 | // By replacing the watcher, we drop the previous one which | 219 | // Replace with a dummy watcher first so we drop the original and wait for completion |
219 | // causes it to shut down automatically. | 220 | std::mem::replace(&mut self.watcher, WatchThread::dummy()); |
221 | |||
222 | // Then create the actual new watcher | ||
220 | self.watcher = WatchThread::new(&self.options, &self.workspace_root); | 223 | self.watcher = WatchThread::new(&self.options, &self.workspace_root); |
221 | } | 224 | } |
222 | } | 225 | } |
@@ -347,7 +350,9 @@ impl WatchThread { | |||
347 | // which will break out of the loop, and continue the shutdown | 350 | // which will break out of the loop, and continue the shutdown |
348 | let _ = message_send.send(CheckEvent::Begin); | 351 | let _ = message_send.send(CheckEvent::Begin); |
349 | 352 | ||
350 | for message in cargo_metadata::parse_messages(command.stdout.take().unwrap()) { | 353 | for message in |
354 | cargo_metadata::parse_messages(BufReader::new(command.stdout.take().unwrap())) | ||
355 | { | ||
351 | let message = match message { | 356 | let message = match message { |
352 | Ok(message) => message, | 357 | Ok(message) => message, |
353 | Err(err) => { | 358 | Err(err) => { |
@@ -356,6 +361,14 @@ impl WatchThread { | |||
356 | } | 361 | } |
357 | }; | 362 | }; |
358 | 363 | ||
364 | // Skip certain kinds of messages to only spend time on what's useful | ||
365 | match &message { | ||
366 | Message::CompilerArtifact(artifact) if artifact.fresh => continue, | ||
367 | Message::BuildScriptExecuted(_) => continue, | ||
368 | Message::Unknown => continue, | ||
369 | _ => {} | ||
370 | } | ||
371 | |||
359 | match message_send.send(CheckEvent::Msg(message)) { | 372 | match message_send.send(CheckEvent::Msg(message)) { |
360 | Ok(()) => {} | 373 | Ok(()) => {} |
361 | Err(_err) => { | 374 | Err(_err) => { |