Skip to content

Commit f376e66

Browse files
authored
Merge pull request #1869 from ahoppen/batch-filedidchange-syntacticindex
Batch updates to the syntactic test index on fileDidChange events
2 parents 2bf4776 + 67b98cd commit f376e66

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/SourceKitLSP/Swift/SyntacticTestIndex.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,24 @@ actor SyntacticTestIndex {
129129
}
130130

131131
func filesDidChange(_ events: [FileEvent]) {
132+
var removedFiles: Set<DocumentURI> = []
133+
var filesToRescan: [DocumentURI] = []
132134
for fileEvent in events {
133135
switch fileEvent.type {
134136
case .created:
135137
// We don't know if this is a potential test file. It would need to be added to the index via
136138
// `listOfTestFilesDidChange`
137139
break
138140
case .changed:
139-
rescanFiles([fileEvent.uri])
141+
filesToRescan.append(fileEvent.uri)
140142
case .deleted:
141-
removeFilesFromIndex([fileEvent.uri])
143+
removedFiles.insert(fileEvent.uri)
142144
default:
143145
logger.error("Ignoring unknown FileEvent type \(fileEvent.type.rawValue) in SyntacticTestIndex")
144146
}
145147
}
148+
removeFilesFromIndex(removedFiles)
149+
rescanFiles(filesToRescan)
146150
}
147151

148152
/// Called when a list of files was updated. Re-scans those files

0 commit comments

Comments
 (0)