@@ -77,8 +77,13 @@ impl FlycheckHandle {
7777 }
7878
7979 /// Schedule a re-start of the cargo check worker.
80- pub fn update ( & self ) {
81- self . sender . send ( Restart ) . unwrap ( ) ;
80+ pub fn restart ( & self ) {
81+ self . sender . send ( Restart :: Yes ) . unwrap ( ) ;
82+ }
83+
84+ /// Stop this cargo check worker.
85+ pub fn cancel ( & self ) {
86+ self . sender . send ( Restart :: No ) . unwrap ( ) ;
8287 }
8388
8489 pub fn id ( & self ) -> usize {
@@ -122,7 +127,10 @@ pub enum Progress {
122127 DidCancel ,
123128}
124129
125- struct Restart ;
130+ enum Restart {
131+ Yes ,
132+ No ,
133+ }
126134
127135struct FlycheckActor {
128136 id : usize ,
@@ -149,6 +157,7 @@ impl FlycheckActor {
149157 config : FlycheckConfig ,
150158 workspace_root : AbsPathBuf ,
151159 ) -> FlycheckActor {
160+ tracing:: info!( %id, ?workspace_root, "Spawning flycheck" ) ;
152161 FlycheckActor { id, sender, config, workspace_root, cargo_handle : None }
153162 }
154163 fn progress ( & self , progress : Progress ) {
@@ -164,10 +173,13 @@ impl FlycheckActor {
164173 fn run ( mut self , inbox : Receiver < Restart > ) {
165174 while let Some ( event) = self . next_event ( & inbox) {
166175 match event {
167- Event :: Restart ( Restart ) => {
176+ Event :: Restart ( Restart :: No ) => {
177+ self . cancel_check_process ( ) ;
178+ }
179+ Event :: Restart ( Restart :: Yes ) => {
168180 // Cancel the previously spawned process
169181 self . cancel_check_process ( ) ;
170- while let Ok ( Restart ) = inbox. recv_timeout ( Duration :: from_millis ( 50 ) ) { }
182+ while let Ok ( _ ) = inbox. recv_timeout ( Duration :: from_millis ( 50 ) ) { }
171183
172184 let command = self . check_command ( ) ;
173185 tracing:: debug!( ?command, "will restart flycheck" ) ;
@@ -223,6 +235,10 @@ impl FlycheckActor {
223235
224236 fn cancel_check_process ( & mut self ) {
225237 if let Some ( cargo_handle) = self . cargo_handle . take ( ) {
238+ tracing:: debug!(
239+ command = ?self . check_command( ) ,
240+ "did cancel flycheck"
241+ ) ;
226242 cargo_handle. cancel ( ) ;
227243 self . progress ( Progress :: DidCancel ) ;
228244 }
0 commit comments