Skip to content
Open
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 @@ -1216,7 +1216,9 @@ private bool PrepareCommandElements(ExecutionContext context, CommandParameterAs
// Pre-processing the arguments -- command arguments
for (commandIndex++; commandIndex < _commandElements.Count; commandIndex++)
{
if (implementsDynamicParameters && _commandElements[commandIndex] == paramAtCursor)
if (implementsDynamicParameters
&& _commandElements[commandIndex] == paramAtCursor
&& !processor.CommandInfo.ExternalCommandMetadata.Parameters.ContainsKey(paramAtCursor.ParameterName))
{
// Commands with dynamic parameters will try to bind the command elements.
// A partially complete parameter will most likely cause a binding error and negatively affect the results.
Expand Down
7 changes: 7 additions & 0 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,13 @@ class InheritedClassTest : System.Attribute
$res.CompletionMatches.CompletionText | Should -Contain '-ProgressAction'
}

It 'Should complete a static parameter at cursor for a command that implements dynamic parameters' {
$script = 'Get-ChildItem -Pat^h $PSHOME'
$cursorIndex = $script.IndexOf('^')
$res = TabExpansion2 -inputScript $script.Remove($cursorIndex, 1) -cursorColumn $cursorIndex
$res.CompletionMatches[0].CompletionText | Should -Be '-Path'
}

It 'Should complete dynamic parameters with partial input' {
# See issue: #19498
try
Expand Down
Loading