Procedure block renames variable in mutator if there is a case change.

This commit is contained in:
marisaleung
2017-08-02 16:49:06 -07:00
parent f08afbb351
commit d37309497f

View File

@@ -443,7 +443,14 @@ Blockly.Blocks['procedures_mutatorarg'] = {
var source = this.sourceBlock_;
if (source && source.workspace && source.workspace.options &&
source.workspace.options.parentWorkspace) {
source.workspace.options.parentWorkspace.createVariable(newText);
var workspace = source.workspace.options.parentWorkspace;
var variable = workspace.getVariable(newText);
// If there is a case change, rename the variable.
if (variable && variable.name !== newText) {
workspace.renameVariableById(variable.getId(), newText);
} else {
workspace.createVariable(newText);
}
}
}
};