Skip to content

Commit 8f8ff45

Browse files
committed
Address review comments to #1326
1 parent 04d8c6b commit 8f8ff45

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Sources/SemanticIndex/SemanticIndexManager.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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

Sources/SourceKitLSP/IndexProgressManager.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)