Fix splatting being treated as positional parameter (#14623)

This commit is contained in:
MartinGC94
2021-06-15 16:56:14 -07:00
committed by GitHub
parent eeabbe7f21
commit 77054ff586
2 changed files with 14 additions and 0 deletions
@@ -1862,6 +1862,13 @@ namespace System.Management.Automation.Language
while (unboundArgumentsIndex < unboundArgumentsCollection.Count)
{
AstParameterArgumentPair argument = unboundArgumentsCollection[unboundArgumentsIndex++];
if (argument is AstPair astPair
&& astPair.Argument is VariableExpressionAst argumentVariable
&& argumentVariable.Splatted)
{
continue;
}
if (!argument.ParameterSpecified)
{
result = argument;
@@ -1022,6 +1022,13 @@ dir -Recurse `
$res.CompletionMatches | Should -HaveCount 4
[string]::Join(',', ($res.CompletionMatches.completiontext | Sort-Object)) | Should -BeExactly "-wa,-Wait,-WarningAction,-WarningVariable"
}
It "Test completion with splatted variable" {
$inputStr = 'Get-Content @Splat -P'
$res = TabExpansion2 -inputScript $inputStr -cursorColumn $inputStr.Length
$res.CompletionMatches | Should -HaveCount 4
[string]::Join(',', ($res.CompletionMatches.completiontext | Sort-Object)) | Should -BeExactly "-Path,-PipelineVariable,-PSPath,-pv"
}
}
Context "Module completion for 'using module'" {