I stumbled across this bug again, having forgotten that this issue had come up earlier.

To summarize what my testing shows, the bug is trigged where there's a /while nested inside another /while. For this to happen, the interior nested /while consists of a single command not enclosed in brackets, and is either in an editbox or is on the same scriptline line as the end-bracket ending the exterior /while. So 2 lines is enough to avoid the early exit, as long as the command is split in one of the right places.

This example alias shows it doesn't matter whether the end-bracket is on a 'normal' next-line, or is an extension of the existing line using $& to continue the same command on the next row. The red countdown exits early unless brackets are added to enclose the /noop. But the purple and green countdowns don't exit early, because the nested /while is split across the two lines:

Code:
alias nested_while {
  var %c $ctime , %i 5 | while (%i) { while (%c == $ctime) noop | var %c $v2 | echo 4 -a i= %i $time | dec %i } | echo -a finish $time
  var %c $ctime , %i 5 | while (%i) { while (%c == $ctime) noop
  var %c $v2 | echo 6 -a i= %i $time | dec %i } | echo -a finish $time
  var %c $ctime , %i 5 | while (%i) { while (%c == $ctime) noop | var %c $v2 | ec $+ $&
    ho 3 -a i= %i $time | dec %i } | echo -a finish $time
}