Rename 'tidyUp' back to 'cleanUp'.

This commit is contained in:
Ben Henning
2024-09-03 23:13:50 +00:00
parent fbafda3e4c
commit 05795a06ea
5 changed files with 22 additions and 22 deletions

View File

@@ -91,7 +91,7 @@ export function registerCleanup() {
return 'hidden';
},
callback(scope: Scope) {
scope.workspace!.tidyUp();
scope.workspace!.cleanUp();
},
scopeType: ContextMenuRegistry.ScopeType.WORKSPACE,
id: 'cleanWorkspace',

View File

@@ -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);

View File

@@ -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();

View File

@@ -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 () {

View File

@@ -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