diff --git a/python/src/com/jetbrains/python/formatter/PyBlock.java b/python/src/com/jetbrains/python/formatter/PyBlock.java index 6abcc29f223c..970a12ccd792 100644 --- a/python/src/com/jetbrains/python/formatter/PyBlock.java +++ b/python/src/com/jetbrains/python/formatter/PyBlock.java @@ -29,7 +29,6 @@ import com.jetbrains.python.PyElementTypes; import com.jetbrains.python.PyTokenTypes; import com.jetbrains.python.PythonDialectsTokenSetProvider; import com.jetbrains.python.psi.*; -import com.jetbrains.python.psi.impl.PyPsiUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -514,13 +513,7 @@ public class PyBlock implements ASTBlock { if (child.getElementType() == PyTokenTypes.COMMA) { return false; } - PyArgumentList argList = (PyArgumentList)_node.getPsi(); - if (argList != null) { - PyExpression[] arguments = argList.getArguments(); - return arguments.length > 1 || hasLineBreaksBefore(child, 1) || ( - arguments.length == 1 && PyPsiUtils.getNextComma(arguments[0].getNode()) != null); - } - return false; + return true; } if (_node.getElementType() == PyElementTypes.PARAMETER_LIST) { return !hasHangingIndent(_node.getPsi()) && myContext.getSettings().ALIGN_MULTILINE_PARAMETERS; diff --git a/python/testData/formatter/alignmentOfClosingParenthesisInNestedFunctionCallsWithSingleArgument.py b/python/testData/formatter/alignmentOfClosingParenthesisInNestedFunctionCallsWithSingleArgument.py new file mode 100644 index 000000000000..47eab4b4716b --- /dev/null +++ b/python/testData/formatter/alignmentOfClosingParenthesisInNestedFunctionCallsWithSingleArgument.py @@ -0,0 +1,5 @@ +with foo(bar(baz(1 + ) + ) + ): + pass diff --git a/python/testData/formatter/alignmentOfClosingParenthesisInNestedFunctionCallsWithSingleArgument_after.py b/python/testData/formatter/alignmentOfClosingParenthesisInNestedFunctionCallsWithSingleArgument_after.py new file mode 100644 index 000000000000..0ee1043627d4 --- /dev/null +++ b/python/testData/formatter/alignmentOfClosingParenthesisInNestedFunctionCallsWithSingleArgument_after.py @@ -0,0 +1,5 @@ +with foo(bar(baz(1 + ) + ) + ): + pass diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java index ebae20fa81c7..d3e11323da59 100644 --- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java +++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java @@ -477,6 +477,10 @@ public class PyFormatterTest extends PyTestCase { doTest(); } + public void testAlignmentOfClosingParenthesisInNestedFunctionCallsWithSingleArgument() { + doTest(); + } + /** * This test merely checks that call to {@link com.intellij.psi.codeStyle.CodeStyleManager#reformat(com.intellij.psi.PsiElement)} * is possible for Python sources.