diff --git a/byob.js b/byob.js index b546cfea..c1dbd04e 100644 --- a/byob.js +++ b/byob.js @@ -104,11 +104,11 @@ contains, InputSlotMorph, ToggleButtonMorph, IDE_Morph, MenuMorph, copy, ToggleElementMorph, Morph, fontHeight, StageMorph, SyntaxElementMorph, SnapSerializer, CommentMorph, localize, CSlotMorph, SpeechBubbleMorph, MorphicPreferences, SymbolMorph, isNil, CursorMorph, VariableFrame, -WatcherMorph*/ +WatcherMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2016-January-11'; +modules.byob = '2016-January-17'; // Declarations @@ -420,11 +420,15 @@ CustomCommandBlockMorph.prototype.init = function (definition, isProto) { } }; -CustomCommandBlockMorph.prototype.initializeVariables = function () { +CustomCommandBlockMorph.prototype.initializeVariables = function (oldVars) { var myself = this; this.variables = new VariableFrame(); this.definition.variableNames.forEach(function (name) { - myself.variables.addVar(name); + var v = oldVars ? oldVars[name] : null; + myself.variables.addVar( + name, + v instanceof Variable ? v.value : null + ); }); }; @@ -463,8 +467,8 @@ CustomCommandBlockMorph.prototype.refresh = function (silently) { }); // initialize block vars - // to do: preserve values of unchanged variable names - this.initializeVariables(); + // preserve values of unchanged variable names + this.initializeVariables(this.variables.vars); // make (double) sure I'm colored correctly this.forceNormalColoring(); diff --git a/history.txt b/history.txt index a5de042f..6d7ce58b 100755 --- a/history.txt +++ b/history.txt @@ -2849,3 +2849,8 @@ end - bulk of 151215 160116 ------ * Blocks: fixed a multi-line input slot layout glitch + +160117 +------ +* BYOB: preserve custom block instances’ block var values when editing their definition +