bartbutenaers / node-red-contrib-blockly

A Node Red node for visual programming a function using Blockly
Apache License 2.0
88 stars 22 forks source link

Recent code changes not evaluated #94

Closed bartbutenaers closed 3 years ago

bartbutenaers commented 3 years ago

When the config screen of the Blockly node is closed, we get the number of syntax errors in the generated Javascript code. The number of errors is stored in node.noerr, which will trigger (via a validator function) a red triangle in the flow editor.

However currently this does not work correctly, when we don't navigate to the "Generated javascript" tabsheet. Indeed the errors are based on the javascript code that was already available when the config screen was opened, not by the current javascript code. So when we close the config screen and open it again, then the error only becomes visible:

blockly_error_bug

Reason is that the setValue of the hidden Ace/Monaco editor seems not to work, so getAnnotations returns the errors in the original javascript code.

I changed the mechanism based on this StackOverflow discussion, so we don't use getAnnotations anymore. Because using a hidden code editor for this purpose, is in fact cheating.

Then it works fine:

blockly_error_solution

Thanks to @Steve-Mcl for pointing me towards this direction ...