-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Check for duplicates
- I have searched for similar issues before opening a new one.
Description
Here is the corresponding makecode issue for this: microsoft/pxt-microbit#6181
MakeCode has recently moved to block inflaters for its flyout caching; we maintain a cache of recycled blocks and use those when creating new elements for our toolbox flyout. Many of our toolbox categories create variables like so:
These variables are added to the workspace's potentialVariableMap, which gets cleared after all of the flyout items are disposed when clearing the flyout. The code for clearing variable maps also deletes all usages of the variables in the map, however the logic seems to exclude potential variables from that deletion which is good because otherwise it would dispose of all the blocks we are recycling.
This generally works as intended except when you drag one of those blocks with a variable out of the flyout. That creates a new variable in the workspace with the same ID as the potential variable. As a result, the variable map clearing code no longer filters out the potential variable usages and deletes all of the cached blocks from the workspace.
I currently have a workaround for this where I remap the variables when recycling blocks if I detect that a variable with the same ID appears in the non-potential variable map of the workspace. Ideally, however, the potential variable and the non-potential variable should have different IDs, or the variable map clearing code should know to skip usages in the flyout.
Reproduction steps
Reproducing this bug requires you to have a block inflater that recycles blocks like in MakeCode, so here are some steps to reproduce on a past version of MakeCode's micro:bit editor.
- go to https://makecode.microbit.org/v7.1.30
- create a new project
- in the toolbox, expand the "Advanced" section and open the Arrays category
- drag the "set list to ..." block out of the flyout
- Open the Arrays category again
- See the missing blocks
Stack trace
No stack traceScreenshots
see microsoft/pxt-microbit#6181
Browsers
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
