@@ -8,8 +8,7 @@ use std::{
88
99use always_assert:: always;
1010use crossbeam_channel:: { select, Receiver } ;
11- use ide:: PrimeCachesProgress ;
12- use ide:: { Canceled , FileId } ;
11+ use ide:: { FileId , PrimeCachesProgress } ;
1312use ide_db:: base_db:: VfsPath ;
1413use lsp_server:: { Connection , Notification , Request , Response } ;
1514use lsp_types:: notification:: Notification as _;
@@ -278,8 +277,6 @@ impl GlobalState {
278277 } ;
279278 }
280279
281- let mut finished = false ;
282-
283280 for progress in prime_caches_progress {
284281 let ( state, message, fraction) ;
285282 match progress {
@@ -297,18 +294,13 @@ impl GlobalState {
297294 state = Progress :: End ;
298295 message = None ;
299296 fraction = 1.0 ;
300- finished = true ;
297+
298+ self . prime_caches_queue . op_completed ( ( ) ) ;
301299 }
302300 } ;
303301
304302 self . report_progress ( "Indexing" , state, message, Some ( fraction) ) ;
305303 }
306-
307- // If the task is cancelled we may observe two `PrimeCachesProgress::Finished` so we
308- // have to make sure to only call `op_completed()` once.
309- if finished {
310- self . prime_caches_queue . op_completed ( ( ) ) ;
311- }
312304 }
313305 Event :: Vfs ( mut task) => {
314306 let _p = profile:: span ( "GlobalState::handle_event/vfs" ) ;
@@ -730,15 +722,13 @@ impl GlobalState {
730722 self . task_pool . handle . spawn_with_sender ( {
731723 let snap = self . snapshot ( ) ;
732724 move |sender| {
733- snap. analysis
734- . prime_caches ( |progress| {
735- sender. send ( Task :: PrimeCaches ( progress) ) . unwrap ( ) ;
736- } )
737- . unwrap_or_else ( |_: Canceled | {
738- // Pretend that we're done, so that the progress bar is removed. Otherwise
739- // the editor may complain about it already existing.
740- sender. send ( Task :: PrimeCaches ( PrimeCachesProgress :: Finished ) ) . unwrap ( )
741- } ) ;
725+ let cb = |progress| {
726+ sender. send ( Task :: PrimeCaches ( progress) ) . unwrap ( ) ;
727+ } ;
728+ match snap. analysis . prime_caches ( cb) {
729+ Ok ( ( ) ) => ( ) ,
730+ Err ( _canceled) => ( ) ,
731+ }
742732 }
743733 } ) ;
744734 }
0 commit comments