Fix splatting being treated as positional parameter (#14623)

This commit is contained in:
MartinGC94 2021-06-16 01:56:14 +02:00 committed by GitHub
parent eeabbe7f21
commit 77054ff586
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -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;

View file

@ -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'" {