Merge pull request #1257 from marisaleung/develop_procedureMutatorRenamesVariables

Procedure block renames variable in mutator if there is a case change.
This commit is contained in:
marisaleung
2017-08-04 14:24:01 -07:00
committed by GitHub

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);
}
}
}
};