Skip to content

Commit

Permalink
Rename 'tidyUp' back to 'cleanUp'.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenHenning committed Sep 3, 2024
1 parent fbafda3 commit 05795a0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion core/contextmenu_items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function registerCleanup() {
return 'hidden';
},
callback(scope: Scope) {
scope.workspace!.tidyUp();
scope.workspace!.cleanUp();
},
scopeType: ContextMenuRegistry.ScopeType.WORKSPACE,
id: 'cleanWorkspace',
Expand Down
4 changes: 2 additions & 2 deletions core/workspace_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions demos/blockfactory/workspacefactory/wfactory_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions tests/mocha/contextmenu_items_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 () {
Expand Down
26 changes: 13 additions & 13 deletions tests/mocha/workspace_svg_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 05795a0

Please sign in to comment.