From 5938c6df3bc400918e882b70c1249590db6bb2d7 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 30 Nov 2018 14:34:14 -0800 Subject: [PATCH 1/3] Fix #2131 --- core/connection.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/core/connection.js b/core/connection.js index 11d26cbd4..990be154c 100644 --- a/core/connection.js +++ b/core/connection.js @@ -360,12 +360,7 @@ Blockly.Connection.prototype.canConnectToPrevious_ = function(candidate) { var isFirstStatementConnection = this == firstStatementConnection; var isNextConnection = this == this.sourceBlock_.nextConnection; - // Complex blocks with no previous connection will not be allowed to connect - // mid-stack. - var sourceHasPreviousConn = this.sourceBlock_.previousConnection != null; - - if (isNextConnection || - (isFirstStatementConnection && !sourceHasPreviousConn)) { + if (isNextConnection || isFirstStatementConnection) { // If the candidate is the first connection in a stack, we can connect. if (!candidate.targetConnection) { return true; From b606bc5ec6caa399eaa274b33383e5b05b68b3a7 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 30 Nov 2018 14:36:37 -0800 Subject: [PATCH 2/3] Don't distinguish between first statement connection and others --- core/connection.js | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/core/connection.js b/core/connection.js index 990be154c..6e978dedc 100644 --- a/core/connection.js +++ b/core/connection.js @@ -355,29 +355,19 @@ Blockly.Connection.prototype.canConnectToPrevious_ = function(candidate) { return false; } - var firstStatementConnection = - this.sourceBlock_.getFirstStatementConnection(); - var isFirstStatementConnection = this == firstStatementConnection; - var isNextConnection = this == this.sourceBlock_.nextConnection; - - if (isNextConnection || isFirstStatementConnection) { - // If the candidate is the first connection in a stack, we can connect. - if (!candidate.targetConnection) { - return true; - } - - var targetBlock = candidate.targetBlock(); - // If it is connected to a real block, game over. - if (!targetBlock.isInsertionMarker()) { - return false; - } - // If it's connected to an insertion marker but that insertion marker - // is the first block in a stack, it's still fine. If that insertion - // marker is in the middle of a stack, it won't work. - return !targetBlock.getPreviousBlock(); + if (!candidate.targetConnection) { + return true; } - console.warn('Returning false by default from canConnectToPrevious_.'); - return false; + + var targetBlock = candidate.targetBlock(); + // If it is connected to a real block, game over. + if (!targetBlock.isInsertionMarker()) { + return false; + } + // If it's connected to an insertion marker but that insertion marker + // is the first block in a stack, it's still fine. If that insertion + // marker is in the middle of a stack, it won't work. + return !targetBlock.getPreviousBlock(); }; /** From 1553096b480e3769bb7dc29b7476960aaeac1b84 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 30 Nov 2018 14:46:09 -0800 Subject: [PATCH 3/3] Check if both sides of a potential connection match, not just one --- core/insertion_marker_manager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/insertion_marker_manager.js b/core/insertion_marker_manager.js index fb2fbd81b..f94677c8d 100644 --- a/core/insertion_marker_manager.js +++ b/core/insertion_marker_manager.js @@ -335,7 +335,8 @@ Blockly.InsertionMarkerManager.prototype.shouldUpdatePreviews_ = function( // Decide whether the new connection has higher priority. if (this.localConnection_ && this.closestConnection_) { // The connection was the same as the current connection. - if (this.closestConnection_ == candidateClosest) { + if (this.closestConnection_ == candidateClosest && + this.localConnection_ == candidateLocal) { return false; } var xDiff = this.localConnection_.x_ + dxy.x - this.closestConnection_.x_;