Skip to content

Commit

Permalink
Merge pull request #546 from parallaxinc/Solo-545
Browse files Browse the repository at this point in the history
Refactor code that looks for active terminal-dependent project blocks.
  • Loading branch information
pjewald authored Jan 22, 2021
2 parents b66e6de + c229035 commit dbcb4b3
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/modules/blocklyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,25 @@ function cloudCompile(text, action, successHandler) {
'scribbler_serial_cursor_xy',
];

let consoleBlockCount = 0;
for (let i = 0; i < consoleBlockList.length; i++) {
consoleBlockCount += Blockly.getMainWorkspace()
.getBlocksByType(consoleBlockList[i], false).length;
for (let index = 0;
!terminalNeeded && index < consoleBlockList.length;
index++) {
const blocks = Blockly.getMainWorkspace().getBlocksByType(
consoleBlockList[index],
false);
if (blocks.length > 0) {
for (let idx= 0; !terminalNeeded && idx < blocks.length; idx++) {
if (blocks[idx].isEnabled()) {
terminalNeeded = 'term';
}
}
}
}

if (consoleBlockCount > 0) {
terminalNeeded = 'term';
} else if (Blockly.getMainWorkspace()
.getBlocksByType('graph_settings', false).length > 0) {
terminalNeeded = 'graph';
if (! terminalNeeded ) {
if (Blockly.getMainWorkspace().getBlocksByType(
'graph_settings', false).length > 0) {
terminalNeeded = 'graph';
}
}
}

Expand Down

0 comments on commit dbcb4b3

Please sign in to comment.