mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Add completion for variables assigned by the Data statement (#19831)
This commit is contained in:
@@ -5656,6 +5656,21 @@ namespace System.Management.Automation
|
||||
parent = parent.Parent;
|
||||
}
|
||||
}
|
||||
|
||||
public override AstVisitAction VisitDataStatement(DataStatementAst dataStatementAst)
|
||||
{
|
||||
if (dataStatementAst.Extent.StartOffset >= StopSearchOffset)
|
||||
{
|
||||
return AstVisitAction.StopVisit;
|
||||
}
|
||||
|
||||
if (dataStatementAst.Variable is not null)
|
||||
{
|
||||
SaveVariableInfo(dataStatementAst.Variable, variableType: null, isConstraint: false);
|
||||
}
|
||||
|
||||
return AstVisitAction.SkipChildren;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Lazy<SortedSet<string>> s_specialVariablesCache = new Lazy<SortedSet<string>>(BuildSpecialVariablesCache);
|
||||
|
||||
@@ -657,6 +657,12 @@ ConstructorTestClass(int i, bool b)
|
||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly Cat
|
||||
}
|
||||
|
||||
It 'Should complete variable assigned with Data statement' {
|
||||
$TestString = 'data MyDataVar {"Hello"};$MyDatav'
|
||||
$res = TabExpansion2 -inputScript $TestString
|
||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly '$MyDataVar'
|
||||
}
|
||||
|
||||
it 'Should complete "Value" parameter value in "Where-Object" for Enum property with no input' {
|
||||
$res = TabExpansion2 -inputScript 'Get-Command | where-Object CommandType -eq '
|
||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly Alias
|
||||
|
||||
Reference in New Issue
Block a user