diff --git a/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs b/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs index 65ad2fb07..1b638a8c9 100644 --- a/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs +++ b/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs @@ -345,7 +345,11 @@ public async Task FindParameterSetsInFileAsync( lineNumber, columnNumber); - if (foundSymbol == null) + // If we are not possibly looking at a Function, we don't + // need to continue because we won't be able to get the + // CommandInfo object. + if (foundSymbol?.SymbolType != SymbolType.Function + && foundSymbol?.SymbolType != SymbolType.Unknown) { return null; } @@ -459,9 +463,12 @@ public async Task GetDefinitionOfSymbolAsync( } } - // if definition is not found in file in the workspace - // look for it in the builtin commands - if (foundDefinition == null) + // if the definition is not found in a file in the workspace + // look for it in the builtin commands but only if the symbol + // we are looking at is possibly a Function. + if (foundDefinition == null + && (foundSymbol.SymbolType == SymbolType.Function + || foundSymbol.SymbolType == SymbolType.Unknown)) { CommandInfo cmdInfo = await CommandHelpers.GetCommandInfoAsync(