mirror of
https://github.com/google/blockly.git
synced 2026-01-12 11:27:14 +01:00
Merge pull request #2233 from rachel-fenichel/bugfix/2216
Ignore insertion markers when checking remaining capacity
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user