Skip to content

Commit ba52e84

Browse files
committed
Use FirstOrDefault()
1 parent 14537f6 commit ba52e84

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/PowerShellEditorServices/Services/PowerShell/Utility/CommandHelpers.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,7 @@ public static async Task<CommandInfo> GetCommandInfoAsync(
9898
.AddArgument(commandName)
9999
.AddParameter("ErrorAction", "Ignore");
100100

101-
CommandInfo commandInfo = null;
102-
foreach (CommandInfo result in await executionService.ExecutePSCommandAsync<CommandInfo>(command, new PowerShellExecutionOptions(), CancellationToken.None).ConfigureAwait(false))
103-
{
104-
commandInfo = result;
105-
break;
106-
}
101+
CommandInfo commandInfo = (await executionService.ExecutePSCommandAsync<CommandInfo>(command, new PowerShellExecutionOptions(), CancellationToken.None).ConfigureAwait(false)).FirstOrDefault();
107102

108103
// Only cache CmdletInfos since they're exposed in binaries they are likely to not change throughout the session.
109104
if (commandInfo?.CommandType == CommandTypes.Cmdlet)

0 commit comments

Comments
 (0)