Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

ControlsFor and ControlsForEach did not support break/continue statements. ControlsWhileUntil failed to reset EscapeMode after break, corrupting outer loop execution, and lacked break/continue support in UNTIL mode.

Changes

ControlsFor.cs & ControlsForEach.cs

  • Added break/continue handling after statement evaluation
  • Reset EscapeMode to None after processing flow control
  • For loops properly increment counter before continue

ControlsWhileUntil.cs

  • Moved break check from before to after statement execution
  • Added continue support for WHILE mode
  • Added break/continue support for UNTIL mode (was missing)
  • Both modes now reset EscapeMode to prevent outer loop corruption

Pattern follows existing ControlsRepeatExt.cs implementation:

statement.Evaluate(context);

if (context.EscapeMode == EscapeMode.Break)
{
  context.EscapeMode = EscapeMode.None;
  break;
}

if (context.EscapeMode == EscapeMode.Continue)
{
  context.EscapeMode = EscapeMode.None;
  continue;
}

Testing

Added 8 tests covering break/continue in for, foreach, while, until loops, plus nested loop isolation.

Original prompt

This section details on the original issue you should resolve

<issue_title>Various issues with break and continue</issue_title>
<issue_description>* for and foreach do not support break and continue at all - could be helpful to support these

  • whileuntil does not reset the EscapeMode after Break which may corrupt execution of outer loops</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 20, 2025 13:10
Co-authored-by: richorama <353138+richorama@users.noreply.github.com>
…l handling

Co-authored-by: richorama <353138+richorama@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix various issues with break and continue support Add break/continue support to for/foreach loops and fix whileuntil EscapeMode handling Nov 20, 2025
Copilot AI requested a review from richorama November 20, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Various issues with break and continue

2 participants