mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
Polish
This commit is contained in:
parent
6438ef9aa3
commit
bc1aa93e7e
2 changed files with 18 additions and 15 deletions
|
@ -157,22 +157,25 @@ impl FlycheckActor {
|
|||
while let Some(event) = self.next_event(&inbox) {
|
||||
match event {
|
||||
Event::Restart(Restart) => {
|
||||
// Drop and cancel the previously spawned process
|
||||
self.cargo_handle.take();
|
||||
if let Some(cargo_handle) = self.cargo_handle.take() {
|
||||
// Cancel the previously spawned process
|
||||
cargo_handle.cancel();
|
||||
}
|
||||
while let Ok(Restart) = inbox.recv_timeout(Duration::from_millis(50)) {}
|
||||
|
||||
self.cancel_check_process();
|
||||
|
||||
let command = self.check_command();
|
||||
let command_f = format!("restart flycheck {command:?}");
|
||||
let command_f = format!("{command:?}");
|
||||
tracing::debug!(?command, "will restart flycheck");
|
||||
match CargoHandle::spawn(command) {
|
||||
Ok(cargo_handle) => {
|
||||
tracing::info!("{}", command_f);
|
||||
tracing::debug!(%command_f, "did restart flycheck");
|
||||
self.cargo_handle = Some(cargo_handle);
|
||||
self.progress(Progress::DidStart);
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("{command_f} failed: {e:?}",);
|
||||
Err(error) => {
|
||||
tracing::error!(%command_f, %error, "failed to restart flycheck");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,7 +292,13 @@ impl CargoHandle {
|
|||
Ok(CargoHandle { child, thread, receiver })
|
||||
}
|
||||
|
||||
fn join(self) -> io::Result<()> {
|
||||
fn cancel(mut self) {
|
||||
let _ = self.child.kill();
|
||||
let _ = self.child.wait();
|
||||
}
|
||||
|
||||
fn join(mut self) -> io::Result<()> {
|
||||
let _ = self.child.kill();
|
||||
let exit_status = self.child.wait()?;
|
||||
let (read_at_least_one_message, error) = self.thread.join()?;
|
||||
if read_at_least_one_message || exit_status.success() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Missing batteries for standard libraries.
|
||||
use std::iter;
|
||||
use std::process::Command;
|
||||
use std::{cmp::Ordering, ops, time::Instant};
|
||||
use std::{io as sio, iter};
|
||||
|
||||
mod macros;
|
||||
pub mod process;
|
||||
|
@ -159,16 +159,10 @@ impl Drop for JodChild {
|
|||
}
|
||||
|
||||
impl JodChild {
|
||||
pub fn spawn(mut command: Command) -> std::io::Result<Self> {
|
||||
pub fn spawn(mut command: Command) -> sio::Result<Self> {
|
||||
command.spawn().map(Self)
|
||||
}
|
||||
|
||||
pub fn wait(self) -> std::io::Result<std::process::ExitStatus> {
|
||||
let mut inner = self.into_inner();
|
||||
let _ = inner.kill();
|
||||
inner.wait()
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> std::process::Child {
|
||||
if cfg!(target_arch = "wasm32") {
|
||||
panic!("no processes on wasm");
|
||||
|
|
Loading…
Reference in a new issue