From b75a77954040b24e99acfe1f9938b479fdaaba5f Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Wed, 20 Jun 2018 12:12:33 -0400 Subject: [PATCH] Call fixUpVariableReferences in installTargets, before emitting the workspace update. --- src/serialization/sb2.js | 7 ------- src/serialization/sb3.js | 7 ------- src/virtual-machine.js | 4 ++++ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/serialization/sb2.js b/src/serialization/sb2.js index 60978eea3..a1533b67f 100644 --- a/src/serialization/sb2.js +++ b/src/serialization/sb2.js @@ -668,13 +668,6 @@ const sb2import = function (json, runtime, optForceSprite, zip) { }; return parseScratchObject(json, runtime, extensions, !optForceSprite, zip) - .then(targets => { - if (optForceSprite && targets.length === 1) { - const target = targets[0]; - target.fixUpVariableReferences(); - } - return targets; - }) .then(targets => ({ targets, extensions diff --git a/src/serialization/sb3.js b/src/serialization/sb3.js index fb4cbeffd..0ecff4ed5 100644 --- a/src/serialization/sb3.js +++ b/src/serialization/sb3.js @@ -937,13 +937,6 @@ const deserialize = function (json, runtime, zip, isSingleSprite) { ((isSingleSprite ? [json] : json.targets) || []).map(target => parseScratchObject(target, runtime, extensions, zip)) ) - .then(targets => { - if (isSingleSprite && targets.length === 1) { - const target = targets[0]; - target.fixUpVariableReferences(); - } - return targets; - }) .then(targets => ({ targets, extensions diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 378f9021a..b0571e52c 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -386,6 +386,10 @@ class VirtualMachine extends EventEmitter { this.editingTarget = targets[0]; } + if (!wholeProject) { + this.editingTarget.fixUpVariableReferences(); + } + // Update the VM user's knowledge of targets and blocks on the workspace. this.emitTargetsUpdate(); this.emitWorkspaceUpdate();