File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -515,6 +515,10 @@ public final actor SemanticIndexManager {
515
515
indexTasks. append ( indexTask)
516
516
517
517
let filesToIndex = targetsBatch. flatMap ( { filesByTarget [ $0] ! } )
518
+ // The number of index tasks that don't currently have an in-progress task associated with it.
519
+ // The denominator in the index progress should get incremented by this amount.
520
+ // We don't want to increment the denominator for tasks that already have an index in progress.
521
+ let newIndexTasks = filesToIndex. filter { inProgressIndexTasks [ $0. sourceFile] == nil } . count
518
522
for file in filesToIndex {
519
523
// The state of `inProgressIndexTasks` will get pushed on from `updateIndexStore`.
520
524
// The updates to `inProgressIndexTasks` from `updateIndexStore` cannot race with setting it to
@@ -526,7 +530,7 @@ public final actor SemanticIndexManager {
526
530
indexTask: indexTask
527
531
)
528
532
}
529
- indexTasksWereScheduled ( filesToIndex . count )
533
+ indexTasksWereScheduled ( newIndexTasks )
530
534
}
531
535
let indexTasksImmutable = indexTasks
532
536
Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ actor IndexProgressManager {
31
31
///
32
32
/// The number of outstanding tasks is determined from the `scheduled` and `executing` tasks in all the
33
33
/// `SemanticIndexManager`s.
34
+ ///
35
+ /// Note that the `queuedIndexTasks` might exceed the number of files in the project, eg. in the following scenario:
36
+ /// - Schedule indexing of A.swift and B.swift -> 0 / 2
37
+ /// - Indexing of A.swift finishes -> 1 / 2
38
+ /// - A.swift is modified and should be indexed again -> 1 / 3
39
+ /// - B.swift finishes indexing -> 2 / 3
40
+ /// - A.swift finishes indexing for the second time -> 3 / 3 -> Status disappears
34
41
private var queuedIndexTasks = 0
35
42
36
43
/// While there are ongoing index tasks, a `WorkDoneProgressManager` that displays the work done progress.
You can’t perform that action at this time.
0 commit comments