Skip to content

Commit ab72ca7

Browse files
committed
Revert unnecessary TryAdd changes.
1 parent 01dae97 commit ab72ca7

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4764,16 +4764,13 @@ private static List<CompletionResult> GetDefaultProviderResults(
47644764
// Save relevant info and try again to get just the names.
47654765
foreach (dynamic child in childItemOutput)
47664766
{
4767-
// TryAdd is used because some providers (like SCCM) may include duplicate PSPaths in a container.
4768-
_ = childrenInfoTable.TryAdd(GetChildNameFromPsObject(child, provider.ItemSeparator), child.PSIsContainer);
4767+
childrenInfoTable.Add(GetChildNameFromPsObject(child, provider.ItemSeparator), child.PSIsContainer);
47694768
}
47704769

47714770
_ = context.Helper.CurrentPowerShell
47724771
.AddCommandWithPreferenceSetting("Microsoft.PowerShell.Management\\Get-ChildItem")
47734772
.AddParameter("LiteralPath", pathInfo.Path)
4774-
.AddParameter("Name")
4775-
.AddCommandWithPreferenceSetting("Microsoft.PowerShell.Utility\\Sort-Object")
4776-
.AddParameter("Unique");
4773+
.AddParameter("Name");
47774774
childItemOutput = context.Helper.ExecuteCurrentPowerShell(out _);
47784775
foreach (PSObject child in childItemOutput)
47794776
{
@@ -4786,12 +4783,8 @@ private static List<CompletionResult> GetDefaultProviderResults(
47864783
foreach (dynamic child in childItemOutput)
47874784
{
47884785
var childName = GetChildNameFromPsObject(child, provider.ItemSeparator);
4789-
4790-
// TryAdd is used because some providers (like SCCM) may include duplicate PSPaths in a container.
4791-
if (childrenInfoTable.TryAdd(childName, child.PSIsContainer))
4792-
{
4793-
childNameList.Add(childName);
4794-
}
4786+
childrenInfoTable.Add(childName, child.PSIsContainer);
4787+
childNameList.Add(childName);
47954788
}
47964789
}
47974790

0 commit comments

Comments
 (0)