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 @@ -566,10 +566,11 @@ internal static List<CompletionResult> CompleteCommandParameter(CompletionContex

PseudoBindingInfo pseudoBinding = new PseudoParameterBinder()
.DoPseudoParameterBinding(commandAst, null, parameterAst, PseudoParameterBinder.BindingType.ParameterCompletion);
// The command cannot be found or it's not a cmdlet, not a script cmdlet, not a function
// The command cannot be found or it's not a cmdlet, not a script cmdlet, not a function.
// Try completing as if it the parameter is a command argument for native command completion.
if (pseudoBinding == null)
{
return result;
return CompleteCommandArgument(context);
}

switch (pseudoBinding.InfoType)
Expand Down
32 changes: 32 additions & 0 deletions test/powershell/Language/Parser/ExtensibleCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,38 @@ Describe "Test extensible completion of native commands" -Tags "CI" {
} | Get-CompletionTestCaseData | Test-Completions
}

Describe "Test completion of parameters for native commands" -Tags "CI" {
Register-ArgumentCompleter -Native -CommandName foo -ScriptBlock {
Param($wordToComplete)

@("-dir", "-verbose", "-help", "-version") |
Where-Object {
$_ -match "$wordToComplete*"
} |
ForEach-Object {
[CompletionResult]::new($_, $_, [CompletionResultType]::ParameterName, $_)
}
}

@{
ExpectedResults = @(
@{CompletionText = "-version"; ResultType = "ParameterName"}
@{CompletionText = "-verbose"; ResultType = "ParameterName"}
@{CompletionText = "-dir"; ResultType = "ParameterName"}
@{CompletionText = "-help"; ResultType = "ParameterName"}
)
TestInput = 'foo -'
} | Get-CompletionTestCaseData | Test-Completions

@{
ExpectedResults = @(
@{CompletionText = "-version"; ResultType = "ParameterName"}
@{CompletionText = "-verbose"; ResultType = "ParameterName"}
)
TestInput = 'foo -v'
} | Get-CompletionTestCaseData | Test-Completions
}

Describe "Test extensible completion of using namespace" -Tags "CI" {
@{
ExpectedResults = @(
Expand Down