@@ -264,9 +264,6 @@ public final actor SemanticIndexManager {
264
264
if let dependentTargets = await buildSystemManager. targets ( dependingOn: targets) {
265
265
await preparationUpToDateStatus. markOutOfDate ( dependentTargets)
266
266
} else {
267
- // We couldn't determine which targets depend on the modified targets. Be conservative and assume all of them do.
268
- await indexStoreUpToDateStatus. markOutOfDate ( changedFiles)
269
-
270
267
await preparationUpToDateStatus. markAllOutOfDate ( )
271
268
// `markAllOutOfDate` only marks targets out-of-date that have been indexed before. Also mark all targets with
272
269
// in-progress preparation out of date. So we don't get into the following situation, which would result in an
@@ -524,17 +521,22 @@ public final actor SemanticIndexManager {
524
521
indexTasks. append ( indexTask)
525
522
526
523
let filesToIndex = targetsBatch. flatMap ( { filesByTarget [ $0] ! } )
524
+ // The number of index tasks that don't currently have an in-progress task associated with it.
525
+ // The denominator in the index progress should get incremented by this amount.
526
+ // We don't want to increment the denominator for tasks that already have an index in progress.
527
+ let newIndexTasks = filesToIndex. filter { inProgressIndexTasks [ $0. sourceFile] == nil } . count
527
528
for file in filesToIndex {
528
- // indexStatus will get set to `.upToDate` by `updateIndexStore`. Setting it to `.upToDate` cannot race with
529
- // setting it to `.scheduled` because we don't have an `await` call between the creation of `indexTask` and
529
+ // The state of `inProgressIndexTasks` will get pushed on from `updateIndexStore`.
530
+ // The updates to `inProgressIndexTasks` from `updateIndexStore` cannot race with setting it to
531
+ // `.waitingForPreparation` here because we don't have an `await` call between the creation of `indexTask` and
530
532
// this loop, so we still have exclusive access to the `SemanticIndexManager` actor and hence `updateIndexStore`
531
- // can't execute until we have set all index statuses to `.scheduled `.
533
+ // can't execute until we have set all index statuses to `.waitingForPreparation `.
532
534
inProgressIndexTasks [ file. sourceFile] = . waitingForPreparation(
533
535
preparationTaskID: preparationTaskID,
534
536
indexTask: indexTask
535
537
)
536
538
}
537
- indexTasksWereScheduled ( filesToIndex . count )
539
+ indexTasksWereScheduled ( newIndexTasks )
538
540
}
539
541
let indexTasksImmutable = indexTasks
540
542
0 commit comments