diff --git a/python/src/com/jetbrains/python/formatter/PyBlock.java b/python/src/com/jetbrains/python/formatter/PyBlock.java index e38fe04eb1b0..46908b2857d1 100644 --- a/python/src/com/jetbrains/python/formatter/PyBlock.java +++ b/python/src/com/jetbrains/python/formatter/PyBlock.java @@ -153,7 +153,9 @@ public class PyBlock implements ASTBlock { childIndent = Indent.getNoneIndent(); } else { - childIndent = Indent.getNormalIndent(); + childIndent = parentType == PyElementTypes.PARAMETER_LIST + ? Indent.getContinuationIndent() + : Indent.getNormalIndent(); } } else if (parentType == PyElementTypes.DICT_LITERAL_EXPRESSION || parentType == PyElementTypes.SET_LITERAL_EXPRESSION) { @@ -483,6 +485,9 @@ public class PyBlock implements ASTBlock { } // constructs that imply indent for their children + if (_node.getElementType().equals(PyElementTypes.PARAMETER_LIST)) { + return Indent.getContinuationIndent(); + } if (ourListElementTypes.contains(_node.getElementType()) || _node.getPsi() instanceof PyStatementPart) { return Indent.getNormalIndent(); } diff --git a/python/testData/formatter/optionalAlignForMethodParameters_after.py b/python/testData/formatter/optionalAlignForMethodParameters_after.py index 106f655c6276..eabb21b286b7 100644 --- a/python/testData/formatter/optionalAlignForMethodParameters_after.py +++ b/python/testData/formatter/optionalAlignForMethodParameters_after.py @@ -1,3 +1,3 @@ def long_method_name(bar, - baz): + baz): pass diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java index fbaf356d4bb4..47a193942322 100644 --- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java +++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java @@ -156,10 +156,10 @@ public class PyFormatterTest extends PyTestCase { String expected = "def method_name(\n" + - " desired_impulse_response,\n" + - " desired_response_parameters,\n" + - " inverse_filter_length,\n" + - " observed_impulse_response):\n" + + " desired_impulse_response,\n" + + " desired_response_parameters,\n" + + " inverse_filter_length,\n" + + " observed_impulse_response):\n" + "# Extract from here to ...\n" + " desired_impulse_response = {'dirac, '\n" + " gaussian\n" + @@ -167,8 +167,8 @@ public class PyFormatterTest extends PyTestCase { " return desired, o"; assertEquals(expected, reformatted.getText()); } - - private void doTest() { + + private void doTest() { myFixture.configureByFile("formatter/" + getTestName(true) + ".py"); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override