Conversation
mikeharv
left a comment
There was a problem hiding this comment.
It actually feels a little fragile to me that we rely on disabling orphans to correctly generate code for the single factory_base block. What if instead of looking at the whole workspace (all top blocks), we just generated code for the single expected top block?
We could add a private method to the Controller that takes a CodeGenerator and calls blockToCode with it, then replace each workspaceToCode call site in the file with this. Then there's no chance of attempting to generate for the wrong block.
Something like:
private generate(generator) {
const baseBlock = ...
generator.init(workspace);
return generator.finish(generator.blockToCode(baseBlock);
}
|
@mikeharv I agree that generating code for just the factory block is better form, but I looked into it and I'd need to also refactor the generators themselves in order to make this work. The header generators return |
The basics
The details
Resolves
Fixes
Proposed Changes
Adds a check to the change listener in
index.tsso that it waits to generate the code output until the blocks that should be disabled are actually disabled.Reason for Changes
This bug predates my changes but I found it while testing. Value blocks don't have header code generators (and they shouldn't). This normally isn't a problem since these blocks are disabled if they're not attached to the factory block. But, value blocks are very briefly top level and enabled when swapping one out for another.
Repro:
Test Coverage
Documentation
Additional Information