Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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 6 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"
}
Comment thread
MartinGC94 marked this conversation as resolved.

Context "Script name completion" {
BeforeAll {
Setup -f 'install-powershell.ps1' -Content ""
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.