diff --git a/core/contextmenu_items.ts b/core/contextmenu_items.ts index 04b94eed7..25ffab59b 100644 --- a/core/contextmenu_items.ts +++ b/core/contextmenu_items.ts @@ -91,7 +91,7 @@ export function registerCleanup() { return 'hidden'; }, callback(scope: Scope) { - scope.workspace!.tidyUp(); + scope.workspace!.cleanUp(); }, scopeType: ContextMenuRegistry.ScopeType.WORKSPACE, id: 'cleanWorkspace', diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index d118c8584..b8ef96292 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -1645,8 +1645,8 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { return boundary; } - /** Tidy up the workspace by ordering all the blocks in a column such that none overlap. */ - tidyUp() { + /** Clean up the workspace by ordering all the blocks in a column such that none overlap. */ + cleanUp() { this.setResizesEnabled(false); eventUtils.setGroup(true); diff --git a/demos/blockfactory/workspacefactory/wfactory_controller.js b/demos/blockfactory/workspacefactory/wfactory_controller.js index 7e2f95c81..385feede8 100644 --- a/demos/blockfactory/workspacefactory/wfactory_controller.js +++ b/demos/blockfactory/workspacefactory/wfactory_controller.js @@ -278,7 +278,7 @@ WorkspaceFactoryController.prototype.clearAndLoadElement = function(id) { this.view.setCategoryTabSelection(id, true); // Order blocks as shown in flyout. - this.toolboxWorkspace.tidyUp(); + this.toolboxWorkspace.cleanUp(); // Update category editing buttons. this.view.updateState(this.model.getIndexByElementId @@ -774,7 +774,7 @@ WorkspaceFactoryController.prototype.importToolboxFromTree_ = function(tree) { // No categories present. // Load all the blocks into a single category evenly spaced. Blockly.Xml.domToWorkspace(tree, this.toolboxWorkspace); - this.toolboxWorkspace.tidyUp(); + this.toolboxWorkspace.cleanUp(); // Convert actual shadow blocks to user-generated shadow blocks. this.convertShadowBlocks(); @@ -799,7 +799,7 @@ WorkspaceFactoryController.prototype.importToolboxFromTree_ = function(tree) { } // Evenly space the blocks. - this.toolboxWorkspace.tidyUp(); + this.toolboxWorkspace.cleanUp(); // Convert actual shadow blocks to user-generated shadow blocks. this.convertShadowBlocks(); diff --git a/tests/mocha/contextmenu_items_test.js b/tests/mocha/contextmenu_items_test.js index ff6f4fe91..a9e2bb3de 100644 --- a/tests/mocha/contextmenu_items_test.js +++ b/tests/mocha/contextmenu_items_test.js @@ -123,7 +123,7 @@ suite('Context Menu Items', function () { suite('Cleanup', function () { setup(function () { this.cleanupOption = this.registry.getItem('cleanWorkspace'); - this.tidyUpStub = sinon.stub(this.workspace, 'tidyUp'); + this.cleanUpStub = sinon.stub(this.workspace, 'cleanUp'); }); test('Enabled when multiple blocks', function () { @@ -153,9 +153,9 @@ suite('Context Menu Items', function () { ); }); - test('Calls workspace tidyUp', function () { + test('Calls workspace cleanUp', function () { this.cleanupOption.callback(this.scope); - sinon.assert.calledOnce(this.tidyUpStub); + sinon.assert.calledOnce(this.cleanUpStub); }); test('Has correct label', function () { diff --git a/tests/mocha/workspace_svg_test.js b/tests/mocha/workspace_svg_test.js index d90c21106..75c0625fb 100644 --- a/tests/mocha/workspace_svg_test.js +++ b/tests/mocha/workspace_svg_test.js @@ -407,9 +407,9 @@ suite('WorkspaceSvg', function () { }); }); - suite('tidyUp', function () { + suite('cleanUp', function () { test('empty workspace does not change', function () { - this.workspace.tidyUp(); + this.workspace.cleanUp(); const blocks = this.workspace.getTopBlocks(true); assert.equal(blocks.length, 0, 'workspace is empty'); @@ -426,7 +426,7 @@ suite('WorkspaceSvg', function () { }; Blockly.serialization.blocks.append(blockJson, this.workspace); - this.workspace.tidyUp(); + this.workspace.cleanUp(); const blocks = this.workspace.getTopBlocks(true); const origin = new Blockly.utils.Coordinate(0, 0); @@ -449,7 +449,7 @@ suite('WorkspaceSvg', function () { }; Blockly.serialization.blocks.append(blockJson, this.workspace); - this.workspace.tidyUp(); + this.workspace.cleanUp(); const topBlocks = this.workspace.getTopBlocks(true); const allBlocks = this.workspace.getAllBlocks(false); @@ -483,7 +483,7 @@ suite('WorkspaceSvg', function () { }; Blockly.serialization.blocks.append(blockJson, this.workspace); - this.workspace.tidyUp(); + this.workspace.cleanUp(); const topBlocks = this.workspace.getTopBlocks(true); const allBlocks = this.workspace.getAllBlocks(false); @@ -516,7 +516,7 @@ suite('WorkspaceSvg', function () { Blockly.serialization.blocks.append(blockJson1, this.workspace); Blockly.serialization.blocks.append(blockJson2, this.workspace); - this.workspace.tidyUp(); + this.workspace.cleanUp(); // block1 and block2 do not switch places since blocks are pre-sorted by their position before // being tidied up, so the order they were added to the workspace doesn't matter. @@ -557,7 +557,7 @@ suite('WorkspaceSvg', function () { Blockly.serialization.blocks.append(blockJson1, this.workspace); Blockly.serialization.blocks.append(blockJson2, this.workspace); - this.workspace.tidyUp(); + this.workspace.cleanUp(); const topBlocks = this.workspace.getTopBlocks(true); const block1 = this.workspace.getBlockById('block1'); @@ -598,7 +598,7 @@ suite('WorkspaceSvg', function () { this.workspace.getGrid().setSpacing(20); this.workspace.getGrid().setSnapToGrid(true); - this.workspace.tidyUp(); + this.workspace.cleanUp(); const topBlocks = this.workspace.getTopBlocks(true); const block1 = this.workspace.getBlockById('block1'); @@ -644,7 +644,7 @@ suite('WorkspaceSvg', function () { Blockly.serialization.blocks.append(blockJson1, this.workspace); Blockly.serialization.blocks.append(blockJson2, this.workspace); - this.workspace.tidyUp(); + this.workspace.cleanUp(); const topBlocks = this.workspace.getTopBlocks(true); const allBlocks = this.workspace.getAllBlocks(false); @@ -733,7 +733,7 @@ suite('WorkspaceSvg', function () { Blockly.serialization.blocks.append(blockJson1, this.workspace); Blockly.serialization.blocks.append(blockJson2, this.workspace); - this.workspace.tidyUp(); + this.workspace.cleanUp(); const topBlocks = this.workspace.getTopBlocks(true); const block1 = this.workspace.getBlockById('block1'); @@ -773,7 +773,7 @@ suite('WorkspaceSvg', function () { Blockly.serialization.blocks.append(blockJson4, this.workspace); Blockly.serialization.blocks.append(blockJson5, this.workspace); - this.workspace.tidyUp(); + this.workspace.cleanUp(); const topBlocks = this.workspace.getTopBlocks(true); const block1Pos = this.workspace @@ -816,7 +816,7 @@ suite('WorkspaceSvg', function () { }; Blockly.serialization.blocks.append(blockJson, this.workspace); - this.workspace.tidyUp(); + this.workspace.cleanUp(); const topBlocks = this.workspace.getTopBlocks(true); const allBlocks = this.workspace.getAllBlocks(false); @@ -907,7 +907,7 @@ suite('WorkspaceSvg', function () { Blockly.serialization.blocks.append(blockJson4, this.workspace); Blockly.serialization.blocks.append(blockJson5, this.workspace); - this.workspace.tidyUp(); + this.workspace.cleanUp(); const topBlocks = this.workspace.getTopBlocks(true); const block1Rect = this.workspace