Dropdown Create does not create a missing variable twice.

This commit is contained in:
marisaleung
2017-06-26 16:50:42 -07:00
parent 693bdbb10e
commit 3c8e0ebbeb
3 changed files with 81 additions and 6 deletions

View File

@@ -148,7 +148,7 @@ Blockly.FieldVariable.dropdownCreate = function() {
if (workspace) {
// Get a copy of the list, so that adding rename and new variable options
// doesn't modify the workspace's list.
var variableModelList = workspace.getVariablesOfType('');
variableModelList = workspace.getVariablesOfType('');
for (var i = 0; i < variableModelList.length; i++){
if (createSelectedVariable &&
goog.string.caseInsensitiveEquals(variableModelList[i].name, name)) {

View File

@@ -211,7 +211,7 @@ Blockly.VariableMap.prototype.getVariablesOfType = function(type) {
type = type || '';
var variable_list = this.variableMap_[type];
if (variable_list) {
return variable_list;
return variable_list.slice();
}
return [];
};