Skip to content

Commit

Permalink
Ignore dot-source commands when finding for Pester document symbols
Browse files Browse the repository at this point in the history
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
  • Loading branch information
daviwil committed Jun 12, 2017
1 parent f39b22d commit 2bb2f8c
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ IEnumerable<SymbolReference> IDocumentSymbolProvider.ProvideDocumentSymbols(

return
commandAst != null &&
commandAst.InvocationOperator != TokenKind.Dot &&
PesterSymbolReference.GetCommandType(commandAst.GetCommandName()).HasValue &&
commandAst.CommandElements.Count >= 2;
},
Expand Down Expand Up @@ -144,6 +145,11 @@ internal PesterSymbolReference(

internal static PesterCommandType? GetCommandType(string commandName)
{
if (commandName == null)
{
return null;
}

switch (commandName.ToLower())
{
case "describe":
Expand Down

0 comments on commit 2bb2f8c

Please sign in to comment.