Skip to content

Commit 90b750d

Browse files
authored
control.js -- make forever escaping a bit more accurate
1 parent 43893c5 commit 90b750d

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

blocks_vertical/control.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ Blockly.Blocks['control_exitLoop'] = {
12621262
this.oldLoopBlock = null;
12631263

12641264
// its rather expensive to start listening to Blockly Events, its lighter to
1265-
// patch this function for this specific block
1265+
// patch these functions for this specific block
12661266
this.originalSetDraggingFunc = this.setDragging;
12671267
this.setDragging = function(adding) {
12681268
this.originalSetDraggingFunc.call(this, adding);
@@ -1271,7 +1271,7 @@ Blockly.Blocks['control_exitLoop'] = {
12711271
if (!this.getParent() && this.oldLoopBlock) {
12721272
var oldMutation = Blockly.Xml.domToText(this.oldLoopBlock.mutationToDom());
12731273
this.oldLoopBlock.setNextStatement(false);
1274-
this.hasBreak_ = false;
1274+
this.oldLoopBlock.hasBreak_ = false;
12751275
this.updateForeverMutation(oldMutation, this.oldLoopBlock);
12761276
this.oldLoopBlock = null;
12771277
}
@@ -1285,6 +1285,19 @@ Blockly.Blocks['control_exitLoop'] = {
12851285
}));
12861286
}
12871287
}
1288+
1289+
this.originalDisconnect = this.previousConnection.disconnect;
1290+
this.previousConnection.disconnect = function(...args) {
1291+
this.originalDisconnect.call(this, ...args);
1292+
1293+
// no need for climbing
1294+
if (this.oldLoopBlock) {
1295+
this.oldLoopBlock.setNextStatement(false);
1296+
this.oldLoopBlock.hasBreak_ = false;
1297+
this.updateForeverMutation(oldMutation, this.oldLoopBlock);
1298+
this.oldLoopBlock = null;
1299+
}
1300+
}
12881301
},
12891302
climbBlockTree: function(callback) {
12901303
// recursively climb tree until we reach a forever loop block

0 commit comments

Comments
 (0)