Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing block deletions problems with some sticky comments #2568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4467,14 +4467,16 @@ BlockMorph.prototype.situation = function () {

// BlockMorph sticky comments

BlockMorph.prototype.prepareToBeGrabbed = function (hand) {
BlockMorph.prototype.prepareToBeGrabbed = function (hand, allAtOnce) {
var myself = this;
this.allInputs().forEach(function (input) {
delete input.bindingID;
});
this.allComments().forEach(function (comment) {
comment.startFollowing(myself, hand.world);
});
if (!allAtOnce) {
this.allComments().forEach(function (comment) {
comment.startFollowing(myself, hand.world);
});
}
};

BlockMorph.prototype.justDropped = function () {
Expand Down Expand Up @@ -4914,15 +4916,15 @@ CommandBlockMorph.prototype.snap = function (hand) {
}
};

CommandBlockMorph.prototype.prepareToBeGrabbed = function (handMorph) {
CommandBlockMorph.prototype.prepareToBeGrabbed = function (handMorph, allAtOnce) {
var oldPos = this.position();

nop(handMorph);
if (this.parent instanceof RingReporterSlotMorph) {
this.parent.revertToDefaultInput(this);
this.setPosition(oldPos);
}
CommandBlockMorph.uber.prepareToBeGrabbed.call(this, handMorph);
CommandBlockMorph.uber.prepareToBeGrabbed.call(this, handMorph, allAtOnce);
};

CommandBlockMorph.prototype.isStop = function () {
Expand Down Expand Up @@ -4963,7 +4965,7 @@ CommandBlockMorph.prototype.userDestroy = function () {
scripts.dropRecord.action = 'delete';
}

this.prepareToBeGrabbed(); // fix outer ring reporter slot
this.prepareToBeGrabbed(this.world().hand, true); // fix outer ring reporter slot and/or sticky comments

if (ide) {
// also stop all active processes hatted by this block
Expand Down Expand Up @@ -5007,7 +5009,7 @@ CommandBlockMorph.prototype.userDestroyJustThis = function () {
above = pb;
} else if (cs && (cs.nestedBlock() === this)) {
above = cs;
this.prepareToBeGrabbed(); // restore ring reporter slot, if any
this.prepareToBeGrabbed(this.world().hand, true); // restore ring reporter slot and/or sticky comments
}
if (ide) {
// also stop all active processes hatted by this block
Expand Down Expand Up @@ -13003,7 +13005,7 @@ ScriptFocusMorph.prototype.deleteLastElement = function () {
} else if (current instanceof ReporterBlockMorph) {
if (!current.isTemplate) {
this.lastElement();
current.prepareToBeGrabbed();
current.prepareToBeGrabbed(this.world().hand, true);
current.destroy();
}
} else if (current instanceof CommandBlockMorph) {
Expand Down