Fix indentation for function blocks with return statements (#1362)

* fix indentation for the return statement in function blocks that return a value

* Fix hard-coded autoindent, and swap it for Blockly.PHP.INDENT

* Fix hard-coded 2 spaces indent and use language-appropriate global indent
This commit is contained in:
Nicole Parrot
2017-10-17 18:20:11 -04:00
committed by Rachel Fenichel
parent 5c00256e96
commit 97ce5b3e4f
5 changed files with 16 additions and 16 deletions

View File

@@ -61,7 +61,7 @@ Blockly.Python['procedures_defreturn'] = function(block) {
var returnValue = Blockly.Python.valueToCode(block, 'RETURN',
Blockly.Python.ORDER_NONE) || '';
if (returnValue) {
returnValue = ' return ' + returnValue + '\n';
returnValue = Blockly.Python.INDENT + 'return ' + returnValue + '\n';
} else if (!branch) {
branch = Blockly.Python.PASS;
}
@@ -117,9 +117,9 @@ Blockly.Python['procedures_ifreturn'] = function(block) {
if (block.hasReturnValue_) {
var value = Blockly.Python.valueToCode(block, 'VALUE',
Blockly.Python.ORDER_NONE) || 'None';
code += ' return ' + value + '\n';
code += Blockly.Python.INDENT + 'return ' + value + '\n';
} else {
code += ' return\n';
code += Blockly.Python.INDENT + 'return\n';
}
return code;
};