@@ -264,9 +264,6 @@ public final actor SemanticIndexManager {
264264 if let dependentTargets = await buildSystemManager. targets ( dependingOn: targets) {
265265 await preparationUpToDateStatus. markOutOfDate ( dependentTargets)
266266 } 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-
270267 await preparationUpToDateStatus. markAllOutOfDate ( )
271268 // `markAllOutOfDate` only marks targets out-of-date that have been indexed before. Also mark all targets with
272269 // 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 {
524521 indexTasks. append ( indexTask)
525522
526523 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
527528 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
530532 // 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 `.
532534 inProgressIndexTasks [ file. sourceFile] = . waitingForPreparation(
533535 preparationTaskID: preparationTaskID,
534536 indexTask: indexTask
535537 )
536538 }
537- indexTasksWereScheduled ( filesToIndex . count )
539+ indexTasksWereScheduled ( newIndexTasks )
538540 }
539541 let indexTasksImmutable = indexTasks
540542
0 commit comments