Skip to content

Commit cd2be90

Browse files
committed
Ignore dot-source commands when finding for Pester document symbols
This change fixes an issue in the PesterDocumentSymbolProvider where CommandAsts for dot-sourced scripts were being evaluated by the symbol provider and causing a crash when GetCommandName() returned null. This change causes dot-sourced commands to now be skipped and also skips any CommandAst which returns null for GetCommandName(). Resolves PowerShell/vscode-powershell#859
1 parent 0c1d459 commit cd2be90

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/PowerShellEditorServices/Symbols/PesterDocumentSymbolProvider.cs

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ IEnumerable<SymbolReference> IDocumentSymbolProvider.ProvideDocumentSymbols(
3333

3434
return
3535
commandAst != null &&
36+
commandAst.InvocationOperator != TokenKind.Dot &&
3637
PesterSymbolReference.GetCommandType(commandAst.GetCommandName()).HasValue &&
3738
commandAst.CommandElements.Count >= 2;
3839
},
@@ -144,6 +145,11 @@ internal PesterSymbolReference(
144145

145146
internal static PesterCommandType? GetCommandType(string commandName)
146147
{
148+
if (commandName == null)
149+
{
150+
return null;
151+
}
152+
147153
switch (commandName.ToLower())
148154
{
149155
case "describe":

0 commit comments

Comments
 (0)