Skip to content

Commit 55b514f

Browse files
committed
Log the source files that are marked in-progress when updating the index status
If we have a bug in index status tracking, this helps figure out which files are considered to be currently indexed.
1 parent e2d5aa7 commit 55b514f

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

Sources/SemanticIndex/SemanticIndexManager.swift

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -711,35 +711,28 @@ package final actor SemanticIndexManager {
711711
// sort files to get deterministic indexing order
712712
.sorted(by: { $0.file.sourceFile.stringValue < $1.file.sourceFile.stringValue })
713713

714-
var alreadyScheduledTasks: Set<FileToIndex> = []
715-
for file in filesToIndex {
716-
let inProgress = inProgressIndexTasks[file.file]
717-
718-
let shouldScheduleIndexing: Bool
719-
switch inProgress?.state {
720-
case nil:
721-
shouldScheduleIndexing = true
722-
case .creatingIndexTask, .waitingForPreparation:
723-
// We already have a task that indexes the file but hasn't started preparation yet. Indexing the file again
724-
// won't produce any new results.
725-
alreadyScheduledTasks.insert(file.file)
726-
shouldScheduleIndexing = false
727-
case .preparing(_, _), .updatingIndexStore(_, _):
728-
// We have started indexing of the file and are now requesting to index it again. Unless we know that the file
729-
// hasn't been modified since the last request for indexing, we need to schedule it to get re-indexed again.
730-
if let modDate = file.fileModificationDate, inProgress?.fileModificationDate == modDate {
731-
shouldScheduleIndexing = false
732-
} else {
733-
shouldScheduleIndexing = true
714+
filesToIndex =
715+
filesToIndex
716+
.filter { file in
717+
let inProgress = inProgressIndexTasks[file.file]
718+
719+
switch inProgress?.state {
720+
case nil:
721+
return true
722+
case .creatingIndexTask, .waitingForPreparation:
723+
// We already have a task that indexes the file but hasn't started preparation yet. Indexing the file again
724+
// won't produce any new results.
725+
return false
726+
case .preparing(_, _), .updatingIndexStore(_, _):
727+
// We have started indexing of the file and are now requesting to index it again. Unless we know that the file
728+
// hasn't been modified since the last request for indexing, we need to schedule it to get re-indexed again.
729+
if let modDate = file.fileModificationDate, inProgress?.fileModificationDate == modDate {
730+
return false
731+
} else {
732+
return true
733+
}
734734
}
735735
}
736-
if shouldScheduleIndexing {
737-
738-
} else {
739-
alreadyScheduledTasks.insert(file.file)
740-
}
741-
}
742-
filesToIndex = filesToIndex.filter { !alreadyScheduledTasks.contains($0.file) }
743736

744737
if filesToIndex.isEmpty {
745738
// Early exit if there are no files to index.

Sources/SourceKitLSP/IndexProgressManager.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ actor IndexProgressManager {
109109
} else {
110110
message = "\(finishedTasks) / \(queuedIndexTasks)"
111111
}
112+
logger.debug("In-progress index tasks: \(indexTasks.map(\.key.sourceFile))")
112113
if queuedIndexTasks != 0 {
113114
percentage = Int(Double(finishedTasks) / Double(queuedIndexTasks) * 100)
114115
} else {

0 commit comments

Comments
 (0)