Skip to content

Commit 5979931

Browse files
committed
Send a DidCancel event when restarting flychecks
1 parent bc1aa93 commit 5979931

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

crates/flycheck/src/lib.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,26 +162,31 @@ impl FlycheckActor {
162162
cargo_handle.cancel();
163163
}
164164
while let Ok(Restart) = inbox.recv_timeout(Duration::from_millis(50)) {}
165-
166-
self.cancel_check_process();
165+
self.progress(Progress::DidCancel);
167166

168167
let command = self.check_command();
169-
let command_f = format!("{command:?}");
170168
tracing::debug!(?command, "will restart flycheck");
171169
match CargoHandle::spawn(command) {
172170
Ok(cargo_handle) => {
173-
tracing::debug!(%command_f, "did restart flycheck");
171+
tracing::debug!(
172+
command = ?self.check_command(),
173+
"did restart flycheck"
174+
);
174175
self.cargo_handle = Some(cargo_handle);
175176
self.progress(Progress::DidStart);
176177
}
177178
Err(error) => {
178-
tracing::error!(%command_f, %error, "failed to restart flycheck");
179+
tracing::error!(
180+
command = ?self.check_command(),
181+
%error, "failed to restart flycheck"
182+
);
179183
}
180184
}
181185
}
182186
Event::CheckEvent(None) => {
183-
// Watcher finished, replace it with a never channel to
184-
// avoid busy-waiting.
187+
tracing::debug!("flycheck finished");
188+
189+
// Watcher finished
185190
let cargo_handle = self.cargo_handle.take().unwrap();
186191
let res = cargo_handle.join();
187192
if res.is_err() {
@@ -209,8 +214,10 @@ impl FlycheckActor {
209214
// If we rerun the thread, we need to discard the previous check results first
210215
self.cancel_check_process();
211216
}
217+
212218
fn cancel_check_process(&mut self) {
213-
if self.cargo_handle.take().is_some() {
219+
if let Some(cargo_handle) = self.cargo_handle.take() {
220+
cargo_handle.cancel();
214221
self.progress(Progress::DidCancel);
215222
}
216223
}

0 commit comments

Comments
 (0)