[release/v7.6] Fix a regression in the API CompletionCompleters.CompleteFilename() that causes null reference exception (#26487)

This commit is contained in:
Travis Plunk
2025-12-05 10:53:01 -08:00
committed by GitHub
parent 932aea6967
commit dfa094e851
2 changed files with 25 additions and 2 deletions
@@ -4580,8 +4580,8 @@ namespace System.Management.Automation
return CommandCompletion.EmptyCompletionResult;
}
var lastAst = context.RelatedAsts[^1];
if (lastAst.Parent is UsingStatementAst usingStatement
var lastAst = context.RelatedAsts?[^1];
if (lastAst?.Parent is UsingStatementAst usingStatement
&& usingStatement.UsingStatementKind is UsingStatementKind.Module or UsingStatementKind.Assembly
&& lastAst.Extent.File is not null)
{