Fix tab completion within the script block specified for the `ValidateScriptAttribute`. (#14550)
This commit is contained in:
parent
19b5647c0a
commit
965dc8f40f
|
@ -1813,9 +1813,14 @@ namespace System.Management.Automation
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = GetResultForAttributeArgument(completionContext, ref replacementIndex, ref replacementLength);
|
||||
if (result != null) return result;
|
||||
if (completionContext.TokenAtCursor.TokenFlags == TokenFlags.MemberName)
|
||||
{
|
||||
result = GetResultForAttributeArgument(completionContext, ref replacementIndex, ref replacementLength);
|
||||
if (result is not null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if ((tokenAtCursor.TokenFlags & TokenFlags.CommandName) != 0)
|
||||
{
|
||||
|
|
|
@ -1097,6 +1097,14 @@ Describe "TabCompletion" -Tags CI {
|
|||
$entry.CompletionText | Should -BeExactly "Mandatory"
|
||||
}
|
||||
|
||||
It "Test Attribute scriptblock completion" {
|
||||
$inputStr = '[ValidateScript({Get-Child})]$Test=ls'
|
||||
$res = TabExpansion2 -inputScript $inputStr -cursorColumn ($inputStr.IndexOf('}'))
|
||||
$res.CompletionMatches | Should -HaveCount 1
|
||||
$entry = $res.CompletionMatches | Where-Object CompletionText -EQ "Get-ChildItem"
|
||||
$entry.CompletionText | Should -BeExactly "Get-ChildItem"
|
||||
}
|
||||
|
||||
It "Test completion with line continuation" {
|
||||
$inputStr = @'
|
||||
dir -Recurse `
|
||||
|
|
Loading…
Reference in New Issue