Skip to content
Merged
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 @@ -5656,6 +5656,21 @@ public override AstVisitAction VisitScriptBlockExpression(ScriptBlockExpressionA
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);
Expand Down
6 changes: 6 additions & 0 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down