tab expansion not working correctly for some parameters (#3364)

There was off by one error causing an `IndexOutOfRangeException` during parameter name completion.
This commit is contained in:
Steve Lee authored and Jason Shirk committed 2017-03-21 08:23:51 -07:00
1 parent 30eb61e3b9
commit c624ae2d6c
2 files changed
+9 -1

No files matched your search

@@ -473,7 +473,7 @@ namespace System.Management.Automation
var argumentAst = specifiedParameter.Argument;
if (argumentAst == null)
{
argumentAst = commandAst.CommandElements[i + 1] as ExpressionAst;
argumentAst = commandAst.CommandElements[i] as ExpressionAst;
if (argumentAst != null)
{
i += 1;
@@ -27,4 +27,12 @@ Describe "Tab completion bug fix" -Tags "CI" {
$result.CompletionMatches.Count | Should Be 1
$result.CompletionMatches[0].CompletionText | Should Be "pscustomobject"
}
It "Issue#1345 - 'Import-Module -n<tab>' should work" {
$cmd = "Import-Module -n"
$result = TabExpansion2 -inputScript $cmd -cursorColumn $cmd.Length
$result.CompletionMatches.Count | Should Be 3
$result.CompletionMatches[0].CompletionText | Should Be "-Name"
$result.CompletionMatches[1].CompletionText | Should Be "-NoClobber"
$result.CompletionMatches[2].CompletionText | Should Be "-NoOverwrite"
}
}