Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4764,17 +4764,20 @@ private static List<CompletionResult> GetDefaultProviderResults(
// Save relevant info and try again to get just the names.
foreach (dynamic child in childItemOutput)
{
childrenInfoTable.Add(GetChildNameFromPsObject(child, provider.ItemSeparator), child.PSIsContainer);
// TryAdd is used because some providers (like SCCM) may include duplicate PSPaths in a container.
_ = childrenInfoTable.TryAdd(GetChildNameFromPsObject(child, provider.ItemSeparator), child.PSIsContainer);
}

_ = context.Helper.CurrentPowerShell
.AddCommandWithPreferenceSetting("Microsoft.PowerShell.Management\\Get-ChildItem")
.AddParameter("LiteralPath", pathInfo.Path)
.AddParameter("Name");
.AddParameter("Name")
.AddCommandWithPreferenceSetting("Microsoft.PowerShell.Utility\\Sort-Object")
.AddParameter("Unique");
childItemOutput = context.Helper.ExecuteCurrentPowerShell(out _);
foreach (var child in childItemOutput)
foreach (PSObject child in childItemOutput)
{
var childName = (string)child.BaseObject;
string childName = (string)child.BaseObject;
childNameList.Add(childName);
}
}
Expand All @@ -4783,8 +4786,12 @@ private static List<CompletionResult> GetDefaultProviderResults(
foreach (dynamic child in childItemOutput)
{
var childName = GetChildNameFromPsObject(child, provider.ItemSeparator);
childrenInfoTable.Add(childName, child.PSIsContainer);
childNameList.Add(childName);

// TryAdd is used because some providers (like SCCM) may include duplicate PSPaths in a container.
if (childrenInfoTable.TryAdd(childName, child.PSIsContainer))
{
childNameList.Add(childName);
}
}
}

Expand Down