From 7a1db20765171e90a0736ccf544a305db67f9729 Mon Sep 17 00:00:00 2001 From: rachel-fenichel Date: Fri, 17 Jun 2016 14:34:28 -0700 Subject: [PATCH] Allow terminal blocks to replace other terminal blocks (#433) * Allow terminal blocks to replace other terminal blocks * Updated test to allow replacing terminal blocks --- core/connection.js | 8 ++++++-- tests/jsunit/connection_test.js | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/connection.js b/core/connection.js index 65d7fd9cf..3b8c82af8 100644 --- a/core/connection.js +++ b/core/connection.js @@ -370,10 +370,14 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate) { } // Don't let a block with no next connection bump other blocks out of the - // stack. + // stack. But covering up a shadow block or stack of shadow blocks is fine. + // Similarly, replacing a terminal statement with another terminal statement + // is allowed. if (this.type == Blockly.PREVIOUS_STATEMENT && candidate.isConnected() && - !this.sourceBlock_.nextConnection) { + !this.sourceBlock_.nextConnection && + !candidate.targetBlock().isShadow() && + candidate.targetBlock().nextConnection) { return false; } diff --git a/tests/jsunit/connection_test.js b/tests/jsunit/connection_test.js index bb0729599..0d10e63ea 100644 --- a/tests/jsunit/connection_test.js +++ b/tests/jsunit/connection_test.js @@ -309,7 +309,8 @@ function test_isConnectionAllowed_NoNext() { three.sourceBlock_.previousConnection = three; Blockly.Connection.connectReciprocally_(one, three); - assertFalse(two.isConnectionAllowed(one)); + // A terminal block is allowed to replace another terminal block. + assertTrue(two.isConnectionAllowed(one)); } function testCheckConnection_Okay() {