Add tab completion for Select-Object -ExcludeProperty -ExpandProperty (#3443)

This commit is contained in:
Ilya
2017-03-29 10:36:18 -07:00
committed by Jason Shirk
parent 27b27cc43a
commit 39be7109d4
2 changed files with 29 additions and 1 deletions
@@ -2249,7 +2249,6 @@ namespace System.Management.Automation
}
case "Group-Object":
case "Measure-Object":
case "Select-Object":
case "Sort-Object":
case "Where-Object":
case "Format-Custom":
@@ -2263,6 +2262,16 @@ namespace System.Management.Automation
}
break;
}
case "Select-Object":
{
if (parameterName.Equals("Property", StringComparison.OrdinalIgnoreCase)
|| parameterName.Equals("ExcludeProperty", StringComparison.OrdinalIgnoreCase)
|| parameterName.Equals("ExpandProperty", StringComparison.OrdinalIgnoreCase))
{
NativeCompletionMemberName(context.WordToComplete, result, commandAst, context);
}
break;
}
case "New-Object":
{
@@ -35,4 +35,23 @@ Describe "Tab completion bug fix" -Tags "CI" {
$result.CompletionMatches[1].CompletionText | Should Be "-NoClobber"
$result.CompletionMatches[2].CompletionText | Should Be "-NoOverwrite"
}
Context "Issue#3416 - 'Select-Object'" {
BeforeAll {
$DatetimeProperties = @((Get-Date).psobject.baseobject.psobject.properties) | Sort-Object -Property Name
}
It "Issue#3416 - 'Select-Object -ExcludeProperty <tab>' should work" {
$cmd = "Get-Date | Select-Object -ExcludeProperty "
$result = TabExpansion2 -inputScript $cmd -cursorColumn $cmd.Length
$result.CompletionMatches.Count | Should Be $DatetimeProperties.Count
$result.CompletionMatches[0].CompletionText | Should Be $DatetimeProperties[0].Name # Date
$result.CompletionMatches[1].CompletionText | Should Be $DatetimeProperties[1].Name # DateTime
}
It "Issue#3416 - 'Select-Object -ExpandProperty <tab>' should work" {
$cmd = "Get-Date | Select-Object -ExpandProperty "
$result = TabExpansion2 -inputScript $cmd -cursorColumn $cmd.Length
$result.CompletionMatches.Count | Should Be $DatetimeProperties.Count
$result.CompletionMatches[0].CompletionText | Should Be $DatetimeProperties[0].Name # Date
$result.CompletionMatches[1].CompletionText | Should Be $DatetimeProperties[1].Name # DateTime
}
}
}