mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Auto merge of #13338 - Veykril:flycheck, r=Veykril
Prioritize restart messages in flycheck cc https://github.com/rust-lang/rust-analyzer/issues/12936#issuecomment-1264670905
This commit is contained in:
commit
f087ebe6e7
@ -169,13 +169,17 @@ impl FlycheckActor {
|
|||||||
}
|
}
|
||||||
fn next_event(&self, inbox: &Receiver<Restart>) -> Option<Event> {
|
fn next_event(&self, inbox: &Receiver<Restart>) -> Option<Event> {
|
||||||
let check_chan = self.cargo_handle.as_ref().map(|cargo| &cargo.receiver);
|
let check_chan = self.cargo_handle.as_ref().map(|cargo| &cargo.receiver);
|
||||||
|
if let Ok(msg) = inbox.try_recv() {
|
||||||
|
// give restarts a preference so check outputs don't block a restart or stop
|
||||||
|
return Some(Event::Restart(msg));
|
||||||
|
}
|
||||||
select! {
|
select! {
|
||||||
recv(inbox) -> msg => msg.ok().map(Event::Restart),
|
recv(inbox) -> msg => msg.ok().map(Event::Restart),
|
||||||
recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())),
|
recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn run(mut self, inbox: Receiver<Restart>) {
|
fn run(mut self, inbox: Receiver<Restart>) {
|
||||||
while let Some(event) = self.next_event(&inbox) {
|
'event: while let Some(event) = self.next_event(&inbox) {
|
||||||
match event {
|
match event {
|
||||||
Event::Restart(Restart::No) => {
|
Event::Restart(Restart::No) => {
|
||||||
self.cancel_check_process();
|
self.cancel_check_process();
|
||||||
@ -183,7 +187,12 @@ impl FlycheckActor {
|
|||||||
Event::Restart(Restart::Yes) => {
|
Event::Restart(Restart::Yes) => {
|
||||||
// Cancel the previously spawned process
|
// Cancel the previously spawned process
|
||||||
self.cancel_check_process();
|
self.cancel_check_process();
|
||||||
while let Ok(_) = inbox.recv_timeout(Duration::from_millis(50)) {}
|
while let Ok(restart) = inbox.recv_timeout(Duration::from_millis(50)) {
|
||||||
|
// restart chained with a stop, so just cancel
|
||||||
|
if let Restart::No = restart {
|
||||||
|
continue 'event;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let command = self.check_command();
|
let command = self.check_command();
|
||||||
tracing::debug!(?command, "will restart flycheck");
|
tracing::debug!(?command, "will restart flycheck");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user