mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix type completion for attribute tokens (#17484)
This commit is contained in:
@@ -424,7 +424,7 @@ namespace System.Management.Automation
|
||||
case TokenKind.Generic:
|
||||
case TokenKind.MinusMinus: // for native commands '--'
|
||||
case TokenKind.Identifier:
|
||||
if (tokenAtCursor.TokenFlags != TokenFlags.TypeName)
|
||||
if (!tokenAtCursor.TokenFlags.HasFlag(TokenFlags.TypeName))
|
||||
{
|
||||
result = GetResultForIdentifier(completionContext, ref replacementIndex, ref replacementLength, isQuotedString);
|
||||
}
|
||||
@@ -1021,7 +1021,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
}
|
||||
|
||||
if (typeNameToComplete is null && tokenAtCursor?.TokenFlags == TokenFlags.TypeName)
|
||||
if (typeNameToComplete is null && tokenAtCursor?.TokenFlags.HasFlag(TokenFlags.TypeName) == true)
|
||||
{
|
||||
typeNameToComplete = new TypeName(tokenAtCursor.Extent, tokenAtCursor.Text);
|
||||
}
|
||||
|
||||
@@ -1209,6 +1209,12 @@ ConstructorTestClass(int i, bool b)
|
||||
$res.CompletionMatches[1].CompletionText | Should -BeExactly 'DarkCyan'
|
||||
}
|
||||
|
||||
It "Tab completion for attribute type" {
|
||||
$inputStr = '[validateset()]$var1'
|
||||
$res = TabExpansion2 -inputScript $inputStr -cursorColumn 2
|
||||
$res.CompletionMatches.CompletionText | Should -Contain 'ValidateSet'
|
||||
}
|
||||
|
||||
It "Tab completion for ArgumentCompleter when AST is passed to CompleteInput" {
|
||||
$scriptBl = {
|
||||
function Test-Completion {
|
||||
|
||||
Reference in New Issue
Block a user