From 3cecc0f604fab6661aab5bab41b8f12a3aa1d9a5 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Wed, 6 Dec 2017 16:57:46 -0800 Subject: [PATCH] Avoid spurious rename event --- core/variable_map.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/variable_map.js b/core/variable_map.js index c9a02aa43..2dc70f8ff 100644 --- a/core/variable_map.js +++ b/core/variable_map.js @@ -107,14 +107,16 @@ Blockly.VariableMap.prototype.renameVariableWithConflict_ = function(variable, var type = variable.type; Blockly.Events.setGroup(true); - Blockly.Events.fire(new Blockly.Events.VarRename(conflictVar, newName)); var oldCase = conflictVar.name; - conflictVar.name = newName; - // These blocks refer to the same variable but the case may have changed. - // No change events should be fired here. var blocks = this.workspace.getAllBlocks(); if (newName != oldCase) { + // Only fire a rename event if the case changed. + Blockly.Events.fire(new Blockly.Events.VarRename(conflictVar, newName)); + conflictVar.name = newName; + + // These blocks refer to the same variable but the case changed. + // No change events should be fired here. for (var i = 0; i < blocks.length; i++) { blocks[i].updateVarName(conflictVar); }