Skip to content

Commit 3fe8b93

Browse files
authored
Merge pull request #1711 from ahoppen/queued-task-isexecuting-status
Set `isExecuting` to `true` before yielding the execution task
2 parents 6888e82 + 8acd7f3 commit 3fe8b93

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Sources/SemanticIndex/SemanticIndexManager.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,12 @@ package final actor SemanticIndexManager {
414414
}
415415
}
416416
if let inProgressPrepareForEditorTask {
417-
logger.debug("Cancelling preparation of \(inProgressPrepareForEditorTask.document) because \(uri) was opened")
417+
// Cancel the in progress prepare for editor task to indicate that we are no longer interested in it.
418+
// This will cancel the preparation of `inProgressPrepareForEditorTask`'s target if it hasn't started yet.
419+
// (see comment at the end of `SemanticIndexManager.prepare`).
420+
logger.debug(
421+
"Marking preparation of \(inProgressPrepareForEditorTask.document) as no longer relevant because \(uri) was opened"
422+
)
418423
inProgressPrepareForEditorTask.task.cancel()
419424
}
420425
inProgressPrepareForEditorTask = InProgressPrepareForEditorTask(

Sources/SemanticIndex/TaskScheduler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ package actor QueuedTask<TaskDescription: TaskDescriptionProtocol> {
244244
}
245245
return await self.finalizeExecution()
246246
}
247+
_isExecuting.value = true
247248
executionTask = task
248249
executionTaskCreatedContinuation.yield(task)
249-
_isExecuting.value = true
250250
await executionStateChangedCallback?(self, .executing)
251251
return await task.value
252252
}

0 commit comments

Comments
 (0)