mit-cml / blockly-plugins

Plugins for Blockly
Apache License 2.0
18 stars 12 forks source link

You have to click outside the block to get warning indicator removed after variable rename #15

Open mark-friedman opened 2 years ago

mark-friedman commented 2 years ago

You shouldn't have to do that. I think that you don't have that behavior in App Inventor, so the bug was introduced when adapting the code for the plugin.

mark-friedman commented 1 year ago

Here's a little video showing the behavior. Note that the warning indicators don't go away until I click outside the variable name field.

https://github.com/mit-cml/blockly-plugins/assets/1743690/31e4d9be-e66c-416f-880d-2c2bb8b66745

mark-friedman commented 1 year ago

Note further, that there shouldn't be any warning indicators at all in this case.

BeksOmega commented 1 year ago

Dug into this this morning! Sorry it took me so long to investigate. I think the difference between this an App Inventor is probably related to how App Inventor handles setting field values differently.

So what's happing is that the lexical variable field's validator is triggering the warning check, but the validator runs before the field's value is actually set. So at the time it checks for warnings, name2 is actually incorrect, because the value of the field is still name.

To solve this I think you can just remove the validator! You're already checking for warnings on every event, so no need to do it an extra time for these fields.

mark-friedman commented 1 year ago

Thank you so much, @BeksOmega! I'll check it out asap.