Skip to content

Commit abf2496

Browse files
Optimize when we run GetCommandInfoAsync (#1237)
* Optimize when we run GetCommandInfoAsync * spacing Co-Authored-By: Robert Holt <[email protected]> Co-authored-by: Robert Holt <[email protected]>
1 parent 8bb7851 commit abf2496

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs

+11-4
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ public async Task<ParameterSetSignatures> FindParameterSetsInFileAsync(
345345
lineNumber,
346346
columnNumber);
347347

348-
if (foundSymbol == null)
348+
// If we are not possibly looking at a Function, we don't
349+
// need to continue because we won't be able to get the
350+
// CommandInfo object.
351+
if (foundSymbol?.SymbolType != SymbolType.Function
352+
&& foundSymbol?.SymbolType != SymbolType.Unknown)
349353
{
350354
return null;
351355
}
@@ -459,9 +463,12 @@ public async Task<SymbolReference> GetDefinitionOfSymbolAsync(
459463
}
460464
}
461465

462-
// if definition is not found in file in the workspace
463-
// look for it in the builtin commands
464-
if (foundDefinition == null)
466+
// if the definition is not found in a file in the workspace
467+
// look for it in the builtin commands but only if the symbol
468+
// we are looking at is possibly a Function.
469+
if (foundDefinition == null
470+
&& (foundSymbol.SymbolType == SymbolType.Function
471+
|| foundSymbol.SymbolType == SymbolType.Unknown))
465472
{
466473
CommandInfo cmdInfo =
467474
await CommandHelpers.GetCommandInfoAsync(

0 commit comments

Comments
 (0)