Metadata
- Source
- C2LC-651
- Type
- New Feature
- Priority
- N/A
- Status
- In Progress
- Resolution
- N/A
- Assignee
- N/A
- Reporter
- Simon Bates
- Created
2022-06-22T11:39:38.607-0400 - Updated
2024-04-24T10:48:46.310-0400 - Versions
- N/A
- Fixed Versions
- N/A
- Component
-
- Coding Environment
Description
Steps to reproduce:
- Make a program: forward, backward
- Play the program, pause such that the programCounter is on backward
- Add a loop to the beginning of the program
- Move the forward and backward blocks into the new loop
Expected:
- The programCounter stays on the backward block
Actual:
- The programCounter moves to the endLoop block
Comments
-
Simon Bates commented
2022-06-28T14:11:48.372-0400 I met with Sepideh and we came up with the following rules:
If we move the block that the programCounter is on, or a loop containing the programCounter, out of a loop at the start, then we set the programCounter to the startLoop block
If we move the block that the programCounter is on, or a loop containing the programCounter, out of a loop at the end, then we advance the programCounter to what would have happened after that block or loop (decrement the number of loop iterations and move the programCounter to the startLoop, or put the programCounter after the loop)
If we move the block that the programCounter is on, or a loop containing the programCounter, into a loop at the start, then we set the programCounter to the startLoop block
If we move the block that the programCounter is on, or a loop containing the programCounter, into a loop at the end, we put the programCounter on the block following the loop (if there is one)
If we move a loop that contains the programCounter to the right, we place the programCounter on what is now before the loop. For example: (startLoop, [forward], endLoop, left) and we move the loop to the right, we get ([left], startLoop, forward, endLoop)
If we move a loop that contains the programCounter to the left, we place the programCounter on what is now after the loop. For example: (forward, startLoop, [left], endLoop) and we move the loop to the left, we get (startLoop, left, endLoop, [forward])
When we move a loop into or out of another loop, we will leave the loop counter as is and not reset
-
Simon Bates commented
2022-06-28T14:24:23.119-0400 The rules above will implement a behaviour different from that in the original issue description. Under these rules the following would happen:
- Make a program: forward, backward
- Play the program, pause such that the programCounter is on backward
- Program is now: forward, [backward]
- Add a loop to the beginning of the program
- Program is now: startLoop, endLoop, forward, [backward]
- Move the forward block into the loop
- Program is now: startLoop, forward, endloop, [backward]
- Move the backward block into the loop
- Program is now: startLoop, forward, backward, endLoop
- And the program is stopped as there is no block after the endLoop
-
Simon Bates commented
2022-06-30T14:22:25.551-0400 Sepideh and I have had more discussion about managing the programCounter when moving blocks while the program is paused. We considered a number of options, listed below, but none stood out strongly to us as being the best choice. We are deferring work to change the behaviour to the future and for now we are going to leave the behaviour as is: when moving blocks, leave the programCounter unchanged.
Options identified:
- Aim to keep execution at the current program position
- This is the current behaviour, with the addition of handling moving loops and moving blocks and loops into and out of loops
- This is the option that we explored above in the rules listed in the first comment
- Move the programCounter with the block being moved, if the block being moved is where the programCounter is
- This feels consistent with the behaviour we have for insertion and deletion
- But it couples the programCounter to the block being moved
- Moving the active block would now move the programCounter and would enable moving the programCounter forwards through the program or backwards through the program, such as into the middle of a loop, or before a loop that has already been executed and whose number of remaining iterations is 0
- Disable movement of blocks when the program is paused and only enable when stopped
- Disable the Control Panel entirely when the program is paused and only enable when stopped
- Remove the ability to pause the program (only Play and Stop) and only support editing when the program is stopped
- Keep the current implementation until we come up with a better solution
- We decided to go with this option for now
- Aim to keep execution at the current program position
-
Simon Bates commented
2022-06-30T15:37:11.334-0400 In preparation for doing C2LC-651, I made some refactoring to the move step code. I have gone ahead and merged in this refactoring. It contains no user-visible behaviour changes but improves the code structure.
-
Simon Bates commented
2024-04-24T10:48:46.310-0400 Moved to GitHub: https://github.com/codelearncreate/c2lc-coding-environment/issues/465