Fix splatting being treated as positional parameter (#14623)
This commit is contained in:
parent
eeabbe7f21
commit
77054ff586
|
@ -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'" {
|
||||
|
|
Loading…
Reference in a new issue