Call fixUpVariableReferences in installTargets, before emitting the workspace update.

This commit is contained in:
Karishma Chadha 2018-06-20 12:12:33 -04:00
parent 889443fcef
commit b75a779540
3 changed files with 4 additions and 14 deletions

View file

@ -668,13 +668,6 @@ const sb2import = function (json, runtime, optForceSprite, zip) {
}; };
return parseScratchObject(json, runtime, extensions, !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 => ({ .then(targets => ({
targets, targets,
extensions extensions

View file

@ -937,13 +937,6 @@ const deserialize = function (json, runtime, zip, isSingleSprite) {
((isSingleSprite ? [json] : json.targets) || []).map(target => ((isSingleSprite ? [json] : json.targets) || []).map(target =>
parseScratchObject(target, runtime, extensions, zip)) parseScratchObject(target, runtime, extensions, zip))
) )
.then(targets => {
if (isSingleSprite && targets.length === 1) {
const target = targets[0];
target.fixUpVariableReferences();
}
return targets;
})
.then(targets => ({ .then(targets => ({
targets, targets,
extensions extensions

View file

@ -386,6 +386,10 @@ class VirtualMachine extends EventEmitter {
this.editingTarget = targets[0]; this.editingTarget = targets[0];
} }
if (!wholeProject) {
this.editingTarget.fixUpVariableReferences();
}
// Update the VM user's knowledge of targets and blocks on the workspace. // Update the VM user's knowledge of targets and blocks on the workspace.
this.emitTargetsUpdate(); this.emitTargetsUpdate();
this.emitWorkspaceUpdate(); this.emitWorkspaceUpdate();