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 {
515515 indexTasks. append ( indexTask)
516516
517517 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
518522 for file in filesToIndex {
519523 // The state of `inProgressIndexTasks` will get pushed on from `updateIndexStore`.
520524 // The updates to `inProgressIndexTasks` from `updateIndexStore` cannot race with setting it to
@@ -526,7 +530,7 @@ public final actor SemanticIndexManager {
526530 indexTask: indexTask
527531 )
528532 }
529- indexTasksWereScheduled ( filesToIndex . count )
533+ indexTasksWereScheduled ( newIndexTasks )
530534 }
531535 let indexTasksImmutable = indexTasks
532536
Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ actor IndexProgressManager {
3131 ///
3232 /// The number of outstanding tasks is determined from the `scheduled` and `executing` tasks in all the
3333 /// `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
3441 private var queuedIndexTasks = 0
3542
3643 /// 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