X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,9 @@ private static void CompletePositionalArgument(
continue;
}

if (bestMatchSet is null || bestMatchSet.Position > positionInParameterSet)
if (bestMatchSet is null
|| bestMatchSet.Position > positionInParameterSet
|| (isDefaultParameterSetValid && positionInParameterSet == bestMatchSet.Position && defaultParameterSetFlag == parameterSetData.ParameterSetFlag))
{
bestMatchParam = param;
bestMatchSet = parameterSetData;
Expand Down
6 changes: 6 additions & 0 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,12 @@ Verb-Noun -Param1 Hello ^
$res.CompletionMatches[0].CompletionText | Should -Be "Get-ChildItem"
}

it 'Should prefer the default parameterset when completing positional parameters' {
$ScriptInput = 'Get-ChildItem | Where-Object '
$res = TabExpansion2 -inputScript $ScriptInput -cursorColumn $ScriptInput.Length
$res.CompletionMatches[0].CompletionText | Should -Be "Attributes"
}

Context "Script name completion" {
BeforeAll {
Setup -f 'install-powershell.ps1' -Content ""
Expand Down
X Tutup