code-dot-org/blockly — pull request #543 by Bjvanminnen (2014-05-02 22:04:39+00:00)
Title: WIP: highlight repeat block while stepping

Right now, when stepping through code in step mode, we only stop on steps that have animations (which is most of them).

When we have a loop that is something like "While path ahead", there's an animation for checking whether we have a path ahead, so we step and highlighting the while block.

For repeat loops, there's no animation, so when stepping we only stop on/highlight children. This can be confusing.

This approach attempts to fix that by injecting a statement into BlocklyApps.log for the start of each loop iteration. Now, when going through our steps we'll stop on/highlight the repeat block.

Downsides:
- Right now I'm just redefining controls_repeat (in maze). This means if the core controls_repeat were to change for some reason, we would not get that change.
- This is a very targeted change. I know that there are at least a few other repeat blocks I'll need to address. Because it's not a general solution, when new blocks are introduced they would also need to know to do this.

Can you think of any better/more generalized ways of doing this? One thing I was considering was having some sort of injection mechanism - something like Blockly.InjectMeIntoLoops = function () {} that apps can use to customize what happens in the loop.