Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0e9cb3a

Browse files
committedAug 25, 2022
Remove null markers to avoid NullReferenceException
1 parent ba293c9 commit 0e9cb3a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎src/PowerShellEditorServices/Services/Analysis/AnalysisService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,11 @@ internal async Task DelayThenInvokeDiagnosticsAsync(ScriptFile[] filesToAnalyze,
384384

385385
private void PublishScriptDiagnostics(ScriptFile scriptFile) => PublishScriptDiagnostics(scriptFile, scriptFile.DiagnosticMarkers);
386386

387-
private void PublishScriptDiagnostics(ScriptFile scriptFile, IReadOnlyList<ScriptFileMarker> markers)
387+
private void PublishScriptDiagnostics(ScriptFile scriptFile, List<ScriptFileMarker> markers)
388388
{
389+
// NOTE: Sometimes we have null markers for reasons we don't yet know, but we need to
390+
// remove them.
391+
_ = markers.RemoveAll(m => m is null);
389392
Diagnostic[] diagnostics = new Diagnostic[markers.Count];
390393

391394
CorrectionTableEntry fileCorrections = _mostRecentCorrectionsByFile.GetOrAdd(

0 commit comments

Comments
 (0)
Please sign in to comment.