about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-06-16 15:25:50 +0200
committerLukas Wirth <lukastw97@gmail.com>2022-06-16 15:25:50 +0200
commit59799312e293b5a5613ec15615e32d651fa4af0b (patch)
tree2b971d27c71f0821cfbadc46a2ada46dd22fd74a
parentbc1aa93e7e85b11325cdd49c46aec23042efb180 (diff)
downloadrust-59799312e293b5a5613ec15615e32d651fa4af0b.tar.gz
rust-59799312e293b5a5613ec15615e32d651fa4af0b.zip
Send a DidCancel event when restarting flychecks
-rw-r--r--crates/flycheck/src/lib.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs
index e327476f3bc..df666ae097b 100644
--- a/crates/flycheck/src/lib.rs
+++ b/crates/flycheck/src/lib.rs
@@ -162,26 +162,31 @@ impl FlycheckActor {
                         cargo_handle.cancel();
                     }
                     while let Ok(Restart) = inbox.recv_timeout(Duration::from_millis(50)) {}
-
-                    self.cancel_check_process();
+                    self.progress(Progress::DidCancel);
 
                     let command = self.check_command();
-                    let command_f = format!("{command:?}");
                     tracing::debug!(?command, "will restart flycheck");
                     match CargoHandle::spawn(command) {
                         Ok(cargo_handle) => {
-                            tracing::debug!(%command_f, "did  restart flycheck");
+                            tracing::debug!(
+                                command = ?self.check_command(),
+                                "did  restart flycheck"
+                            );
                             self.cargo_handle = Some(cargo_handle);
                             self.progress(Progress::DidStart);
                         }
                         Err(error) => {
-                            tracing::error!(%command_f, %error, "failed to restart flycheck");
+                            tracing::error!(
+                                command = ?self.check_command(),
+                                %error, "failed to restart flycheck"
+                            );
                         }
                     }
                 }
                 Event::CheckEvent(None) => {
-                    // Watcher finished, replace it with a never channel to
-                    // avoid busy-waiting.
+                    tracing::debug!("flycheck finished");
+
+                    // Watcher finished
                     let cargo_handle = self.cargo_handle.take().unwrap();
                     let res = cargo_handle.join();
                     if res.is_err() {
@@ -209,8 +214,10 @@ impl FlycheckActor {
         // If we rerun the thread, we need to discard the previous check results first
         self.cancel_check_process();
     }
+
     fn cancel_check_process(&mut self) {
-        if self.cargo_handle.take().is_some() {
+        if let Some(cargo_handle) = self.cargo_handle.take() {
+            cargo_handle.cancel();
             self.progress(Progress::DidCancel);
         }
     }