From f602a69a858ad5fa5bb5bfb461198a5e1ae75a54 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 8 Jun 2020 12:21:04 +0200 Subject: [PATCH] made sure edited custom bloc specs are unique --- snap.html | 2 +- src/byob.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/snap.html b/snap.html index df06f190..34fa6445 100755 --- a/snap.html +++ b/snap.html @@ -13,7 +13,7 @@ - + diff --git a/src/byob.js b/src/byob.js index d720e195..f25c5286 100644 --- a/src/byob.js +++ b/src/byob.js @@ -108,7 +108,7 @@ BooleanSlotMorph, XML_Serializer, SnapTranslator*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2020-May-27'; +modules.byob = '2020-June-08'; // Declarations @@ -2258,6 +2258,7 @@ BlockEditorMorph.prototype.updateDefinition = function () { var head, ide, oldSpec = this.definition.blockSpec(), pos = this.body.contents.position(), + count = 0, element; this.definition.receiver = this.target; // only for serialization @@ -2297,6 +2298,13 @@ BlockEditorMorph.prototype.updateDefinition = function () { } this.definition.body = this.context(head); + + // make sure the spec is unique + while (this.target.doubleDefinitionsFor(this.definition).length > 0) { + count += 1; + this.definition.spec = this.definition.spec + ' (' + count + ')'; + } + this.refreshAllBlockInstances(oldSpec); ide = this.target.parentThatIsA(IDE_Morph); ide.flushPaletteCache();