diff --git a/src/engine/variable.js b/src/engine/variable.js index 4aad9ffc2..c56a3cf01 100644 --- a/src/engine/variable.js +++ b/src/engine/variable.js @@ -33,8 +33,9 @@ class Variable { } } - toXML () { - return `${this.name}`; + toXML (isLocal) { + isLocal = (isLocal === true); + return `${this.name}`; } /** diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 940991e49..922c2fc20 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -1074,19 +1074,21 @@ class VirtualMachine extends EventEmitter { const id = messageIds[i]; delete this.runtime.getTargetForStage().variables[id]; } - const variableMap = Object.assign({}, - this.runtime.getTargetForStage().variables, - this.editingTarget.variables - ); + const globalVarMap = Object.assign({}, this.runtime.getTargetForStage().variables); + const localVarMap = this.editingTarget.isStage ? + Object.create(null) : + Object.assign({}, this.editingTarget.variables); - const variables = Object.keys(variableMap).map(k => variableMap[k]); + const globalVariables = Object.keys(globalVarMap).map(k => globalVarMap[k]); + const localVariables = Object.keys(localVarMap).map(k => localVarMap[k]); const workspaceComments = Object.keys(this.editingTarget.comments) .map(k => this.editingTarget.comments[k]) .filter(c => c.blockId === null); const xmlString = ` - ${variables.map(v => v.toXML()).join()} + ${globalVariables.map(v => v.toXML()).join()} + ${localVariables.map(v => v.toXML(true)).join()} ${workspaceComments.map(c => c.toXML()).join()} ${this.editingTarget.blocks.toXML(this.editingTarget.comments)}