@@ -5546,7 +5546,7 @@ private sealed class VariableInfo
5546
5546
internal Type LastAssignedType ;
5547
5547
}
5548
5548
5549
- private sealed class FindVariablesVisitor : AstVisitor
5549
+ private sealed class FindVariablesVisitor : AstVisitor2
5550
5550
{
5551
5551
internal Ast Top ;
5552
5552
internal Ast CompletionVariableAst ;
@@ -5621,7 +5621,11 @@ public override AstVisitAction DefaultVisit(Ast ast)
5621
5621
{
5622
5622
if ( ast . Extent . StartOffset > StopSearchOffset )
5623
5623
{
5624
- return AstVisitAction . StopVisit ;
5624
+ // When visiting do while/until statements, the condition will be visited before the statement block.
5625
+ // The condition itself may not be interesting if it's after the cursor, but the statement block could be.
5626
+ return ast is PipelineBaseAst && ast . Parent is DoUntilStatementAst or DoWhileStatementAst
5627
+ ? AstVisitAction . SkipChildren
5628
+ : AstVisitAction . StopVisit ;
5625
5629
}
5626
5630
5627
5631
return AstVisitAction . Continue ;
@@ -5631,7 +5635,9 @@ public override AstVisitAction VisitAssignmentStatement(AssignmentStatementAst a
5631
5635
{
5632
5636
if ( assignmentStatementAst . Extent . StartOffset > StopSearchOffset )
5633
5637
{
5634
- return AstVisitAction . StopVisit ;
5638
+ return assignmentStatementAst . Parent is DoUntilStatementAst or DoWhileStatementAst ?
5639
+ AstVisitAction . SkipChildren
5640
+ : AstVisitAction . StopVisit ;
5635
5641
}
5636
5642
5637
5643
if ( assignmentStatementAst . Left is AttributedExpressionAst attributedExpression )
0 commit comments