@@ -8,8 +8,7 @@ use std::{
8
8
9
9
use always_assert:: always;
10
10
use crossbeam_channel:: { select, Receiver } ;
11
- use ide:: PrimeCachesProgress ;
12
- use ide:: { Canceled , FileId } ;
11
+ use ide:: { FileId , PrimeCachesProgress } ;
13
12
use ide_db:: base_db:: VfsPath ;
14
13
use lsp_server:: { Connection , Notification , Request , Response } ;
15
14
use lsp_types:: notification:: Notification as _;
@@ -278,8 +277,6 @@ impl GlobalState {
278
277
} ;
279
278
}
280
279
281
- let mut finished = false ;
282
-
283
280
for progress in prime_caches_progress {
284
281
let ( state, message, fraction) ;
285
282
match progress {
@@ -297,18 +294,13 @@ impl GlobalState {
297
294
state = Progress :: End ;
298
295
message = None ;
299
296
fraction = 1.0 ;
300
- finished = true ;
297
+
298
+ self . prime_caches_queue . op_completed ( ( ) ) ;
301
299
}
302
300
} ;
303
301
304
302
self . report_progress ( "Indexing" , state, message, Some ( fraction) ) ;
305
303
}
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
- }
312
304
}
313
305
Event :: Vfs ( mut task) => {
314
306
let _p = profile:: span ( "GlobalState::handle_event/vfs" ) ;
@@ -730,15 +722,13 @@ impl GlobalState {
730
722
self . task_pool . handle . spawn_with_sender ( {
731
723
let snap = self . snapshot ( ) ;
732
724
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
+ }
742
732
}
743
733
} ) ;
744
734
}
0 commit comments