Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
  • Loading branch information
Tadas and Copilot authored Dec 19, 2025
commit cecc0be2d7fda5486be39ba0e9f9e71d2e521748
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ internal async Task DelayThenInvokeDiagnosticsAsync(ScriptFile fileToAnalyze, Co
// Shouldn't start a new analysis task until:
// 1. Delay/debounce period finishes (i.e. user has not started typing again)
// 2. Previous analysis task finishes (runspace pool is capped at 1, so we'd be sitting in a queue there)
Task debounceAndPrevious = Task.WhenAll(Task.Delay(_analysisDelayMillis), previousAnalysisTask ?? Task.CompletedTask);
Task debounceAndPrevious = Task.WhenAll(Task.Delay(_analysisDelayMillis), previousAnalysisTask);

// In parallel, we will keep an eye on our cancellation token
Task cancellationTask = Task.Delay(Timeout.Infinite, cancellationToken);
Expand All @@ -370,7 +370,8 @@ internal async Task DelayThenInvokeDiagnosticsAsync(ScriptFile fileToAnalyze, Co
// Try to take the place of the currently running task by atomically writing our task in the fileAnalysisEntry.
Task valueAtExchange = Interlocked.CompareExchange(ref fileAnalysisEntry.DiagnosticPublish, placeholder.Task, previousAnalysisTask);

if (valueAtExchange != previousAnalysisTask) {
if (valueAtExchange != previousAnalysisTask)
{
// Some other task has managed to jump in front of us i.e. fileAnalysisEntry.DiagnosticPublish is
// no longer equal to previousAnalysisTask which we noted down at the start of this method
_logger.LogDebug("Failed to claim the running analysis task spot");
Expand Down