Merge pull request #2233 from rachel-fenichel/bugfix/2216

Ignore insertion markers when checking remaining capacity
This commit is contained in:
Rachel Fenichel
2019-01-25 13:27:51 -08:00
committed by GitHub

View File

@@ -513,7 +513,18 @@ Blockly.Workspace.prototype.remainingCapacity = function() {
if (isNaN(this.options.maxBlocks)) {
return Infinity;
}
return this.options.maxBlocks - this.getAllBlocks().length;
// Insertion markers exist on the workspace for rendering reasons, but should
// be ignored in capacity calculation because they dissolve at the end of a
// drag.
var allBlocks = this.getAllBlocks();
var allBlocksCount = allBlocks.length;
for (var i = 0; i < allBlocks.length; i++) {
if (allBlocks[i].isInsertionMarker()) {
allBlocksCount--;
}
}
return this.options.maxBlocks - allBlocksCount;
};
/**