fix several function bugs in new blockly #10402
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this fixes a few bugs with functions in new blockly that were discovered on livestream. namely:
to fix all these issues, i've overhauled how the mutation of function blocks works. firstly, our old implementation disposed all of the argument inputs when a function was edited and then recreated them which led to the shadow issue mentioned above. now, only the edited arguments are created/destroyed. the rest of the inputs on the block are simply reordered.
secondly, we no longer rely on the blockly events spawned by editing the inputs on all of the changed blocks to handle undo/redo because keeping all of those events in sync was causing a lot of issues with edge cases. instead, i've created a custom blockly event that wraps up all of the edits for the mutation in one tidy package.
finally, the function flyout is now cached on the hash of its blocks rather than by its name. since we're essentially busting the cache here, i also tweaked our flyout so that the cache doesn't grow indefinitely. old cache entries now get evicted once we get to 20
there were a ton of tiny bugs here, so i look forward to everyone really hammering on this code in testing!