Skip to content

Commit 1e0639c

Browse files
authored
Merge pull request #1478 from ahoppen/log-prepare-for-editor-preparation
2 parents 55ef104 + 3788a45 commit 1e0639c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Sources/SemanticIndex/SemanticIndexManager.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,10 @@ public final actor SemanticIndexManager {
400400
}
401401
}
402402
}
403-
inProgressPrepareForEditorTask?.task.cancel()
403+
if let inProgressPrepareForEditorTask {
404+
logger.debug("Cancelling preparation of \(inProgressPrepareForEditorTask.document) because \(uri) was opened")
405+
inProgressPrepareForEditorTask.task.cancel()
406+
}
404407
inProgressPrepareForEditorTask = InProgressPrepareForEditorTask(
405408
id: id,
406409
document: uri,

Tests/SourceKitLSPTests/ExpectedIndexTaskTracker.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import LSPLogging
1314
import LanguageServerProtocol
1415
import SKCore
1516
import SemanticIndex
@@ -103,6 +104,7 @@ actor ExpectedIndexTaskTracker {
103104
return
104105
}
105106
if Task.isCancelled {
107+
logger.debug("Ignoring preparation task start because task is cancelled: \(taskDescription.targetsToPrepare)")
106108
return
107109
}
108110
guard let expectedTargetsToPrepare = expectedPreparations.first else {
@@ -120,6 +122,7 @@ actor ExpectedIndexTaskTracker {
120122
return
121123
}
122124
if Task.isCancelled {
125+
logger.debug("Ignoring preparation task finish because task is cancelled: \(taskDescription.targetsToPrepare)")
123126
return
124127
}
125128
guard let expectedTargetsToPrepare = expectedPreparations.first else {
@@ -147,6 +150,12 @@ actor ExpectedIndexTaskTracker {
147150

148151
func updateIndexStoreTaskDidStart(taskDescription: UpdateIndexStoreTaskDescription) -> Void {
149152
if Task.isCancelled {
153+
logger.debug(
154+
"""
155+
Ignoring update indexstore start because task is cancelled: \
156+
\(taskDescription.filesToIndex.map(\.file.sourceFile))
157+
"""
158+
)
150159
return
151160
}
152161
guard let expectedFilesToIndex = expectedIndexStoreUpdates?.first else {
@@ -165,6 +174,12 @@ actor ExpectedIndexTaskTracker {
165174
return
166175
}
167176
if Task.isCancelled {
177+
logger.debug(
178+
"""
179+
Ignoring update indexstore finish because task is cancelled: \
180+
\(taskDescription.filesToIndex.map(\.file.sourceFile))
181+
"""
182+
)
168183
return
169184
}
170185
guard let expectedFilesToIndex = expectedIndexStoreUpdates.first else {

0 commit comments

Comments
 (0)