From a30ad6ff3ab5f4c57591565a96907fd9f32c947d Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 12 Jan 2018 13:28:17 -0800 Subject: [PATCH] More code cleanup for review --- core/variable_map.js | 9 +++++++-- core/variables.js | 2 +- core/workspace_svg.js | 22 ---------------------- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/core/variable_map.js b/core/variable_map.js index daeced960..d97f5832a 100644 --- a/core/variable_map.js +++ b/core/variable_map.js @@ -266,14 +266,19 @@ Blockly.VariableMap.prototype.deleteVariableById = function(id) { */ Blockly.VariableMap.prototype.deleteVariableInternal_ = function(variable, uses) { - Blockly.Events.setGroup(true); + var existingGroup = Blockly.Events.getGroup(); + if (!existingGroup) { + Blockly.Events.setGroup(true); + } try { for (var i = 0; i < uses.length; i++) { uses[i].dispose(true, false); } this.deleteVariable(variable); } finally { - Blockly.Events.setGroup(false); + if (!existingGroup) { + Blockly.Events.setGroup(false); + } } }; diff --git a/core/variables.js b/core/variables.js index 2b591bf82..224aa20c6 100644 --- a/core/variables.js +++ b/core/variables.js @@ -367,7 +367,7 @@ Blockly.Variables.generateVariableFieldXml_ = function(variableModel) { typeString = '\'\''; } var text = '' + goog.string.htmlEscape(variableModel.name) + ''; return text; }; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index db06de3f2..4ce9525d4 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -928,17 +928,6 @@ Blockly.WorkspaceSvg.prototype.refreshToolboxSelection_ = function() { } }; -/** - * Rename a variable by updating its name in the variable list. - * @param {string} oldName Variable to rename. - * @param {string} newName New variable name. - * @package - */ -Blockly.WorkspaceSvg.prototype.renameVariable = function(oldName, newName) { - Blockly.WorkspaceSvg.superClass_.renameVariable.call(this, oldName, newName); - this.refreshToolboxSelection_(); -}; - /** * Rename a variable by updating its name in the variable map. Update the * flyout to show the renamed variable immediately. @@ -951,17 +940,6 @@ Blockly.WorkspaceSvg.prototype.renameVariableById = function(id, newName) { this.refreshToolboxSelection_(); }; -/** - * Delete a variable by the passed in name. Update the flyout to show - * immediately that the variable is deleted. - * @param {string} name Name of variable to delete. - * @package - */ -Blockly.WorkspaceSvg.prototype.deleteVariable = function(name) { - Blockly.WorkspaceSvg.superClass_.deleteVariable.call(this, name); - this.refreshToolboxSelection_(); -}; - /** * Delete a variable by the passed in ID. Update the flyout to show * immediately that the variable is deleted.