Skip to content

Commit

Permalink
Fix nested block inside else
Browse files Browse the repository at this point in the history
- This adds required line breaks in the generated `else` code;
- This fixes label generation for the `while` block.

Fix #109 

Merge pull request #114 from haroldo-ok/fix-nested-block-inside-else
  • Loading branch information
haroldo-ok authored Oct 7, 2024
2 parents e3e7df5 + 0a7dabe commit 27340d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vcs-game-maker",
"version": "0.25.2",
"version": "0.25.3",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
7 changes: 5 additions & 2 deletions src/generators/bbasic/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ export default (Blockly) => {
Blockly.BBasic.injectId(Blockly.BBasic.STATEMENT_SUFFIX,
block), Blockly.BBasic.INDENT) + branchCode;
}
code += '\n' + branchCode +
`@ ${labelStart}_else_end`;
code += [
'\n',
branchCode,
`@ ${labelStart}_else_end`,
].join('\n');
}
return '\n' + code + '\n';
};
Expand Down
3 changes: 2 additions & 1 deletion src/generators/bbasic/loops.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export default (Blockly) => {

Blockly.BBasic['controls_whileUntil'] = function(block) {
// Do while/until loop.
const labelName = Blockly.BBasic.nameDB_.getName('while', Blockly.PROCEDURE_CATEGORY_NAME);
const blockNumber = Blockly.BBasic.blockNumbers.next();
const labelName = `_while_${blockNumber}_`;
const startLabelName = labelName + 'start';
const endLabelName = labelName + 'end';
const until = block.getFieldValue('MODE') == 'UNTIL';
Expand Down

0 comments on commit 27340d9

Please sign in to comment.