]> git.lizzy.rs Git - rust.git/commitdiff
Fix the endless progress bar issue
authorKirill Bulatov <mail4score@gmail.com>
Mon, 30 Mar 2020 11:38:01 +0000 (14:38 +0300)
committerKirill Bulatov <mail4score@gmail.com>
Mon, 30 Mar 2020 11:38:01 +0000 (14:38 +0300)
crates/ra_cargo_watch/src/lib.rs

index c67ec39d48c0d1902de127bd484ba977a24710c0..2692c1bf55208431290c291e639da7517baa6198 100644 (file)
@@ -95,6 +95,9 @@ fn new(options: CheckOptions, workspace_root: PathBuf) -> CheckWatcherThread {
     }
 
     fn run(&mut self, task_send: &Sender<CheckTask>, cmd_recv: &Receiver<CheckCommand>) {
+        // If we rerun the thread, we need to discard the previous check results first
+        self.clean_previous_results(task_send);
+
         loop {
             select! {
                 recv(&cmd_recv) -> cmd => match cmd {
@@ -127,6 +130,13 @@ fn run(&mut self, task_send: &Sender<CheckTask>, cmd_recv: &Receiver<CheckComman
         }
     }
 
+    fn clean_previous_results(&self, task_send: &Sender<CheckTask>) {
+        task_send.send(CheckTask::ClearDiagnostics).unwrap();
+        task_send
+            .send(CheckTask::Status(WorkDoneProgress::End(WorkDoneProgressEnd { message: None })))
+            .unwrap();
+    }
+
     fn should_recheck(&mut self) -> bool {
         if let Some(_last_update_req) = &self.last_update_req {
             // We currently only request an update on save, as we need up to