mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Add tab completion for Select-Object -ExcludeProperty -ExpandProperty (#3443)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user