mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix #682 - [system.manage<Tab>] doesn't work
This commit is contained in:
@@ -5907,21 +5907,32 @@ namespace System.Management.Automation
|
||||
/// <param name="namespace">The namespace</param>
|
||||
private static void HandleNamespace(Dictionary<string, TypeCompletionMapping> entryCache, string @namespace)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(@namespace))
|
||||
if (string.IsNullOrEmpty(@namespace))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int dotIndex = 0;
|
||||
while (dotIndex != -1)
|
||||
{
|
||||
dotIndex = @namespace.IndexOf('.', dotIndex + 1);
|
||||
string subNamespace = dotIndex != -1
|
||||
? @namespace.Substring(0, dotIndex)
|
||||
: @namespace;
|
||||
|
||||
TypeCompletionMapping entry;
|
||||
if (!entryCache.TryGetValue(@namespace, out entry))
|
||||
if (!entryCache.TryGetValue(subNamespace, out entry))
|
||||
{
|
||||
entry = new TypeCompletionMapping
|
||||
{
|
||||
Key = @namespace,
|
||||
Completions = { new NamespaceCompletion { Namespace = @namespace } }
|
||||
Key = subNamespace,
|
||||
Completions = { new NamespaceCompletion { Namespace = subNamespace } }
|
||||
};
|
||||
entryCache.Add(@namespace, entry);
|
||||
entryCache.Add(subNamespace, entry);
|
||||
}
|
||||
else if (!entry.Completions.OfType<NamespaceCompletion>().Any())
|
||||
{
|
||||
entry.Completions.Add(new NamespaceCompletion { Namespace = @namespace });
|
||||
entry.Completions.Add(new NamespaceCompletion { Namespace = subNamespace });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
Describe "Issue#682 - [system.manage<tab>] should work" {
|
||||
|
||||
It "[system.manage<tab>" {
|
||||
$result = TabExpansion2 -inputScript "[system.manage" -cursorColumn "[system.manage".Length
|
||||
$result | Should Not BeNullOrEmpty
|
||||
$result.CompletionMatches.Count | Should Be 1
|
||||
$result.CompletionMatches[0].CompletionText | Should Be "System.Management"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user