PY-10182 Use same indentation level instead of alignment for closing parenthesis in "from" imports

This way the position of the parenthesis doesn't depend on the option
ALIGN_MULTIPLE_IMPORTS, because if it's disabled and there is
hanging indent, import elements inside parentheses don't have any
alignment to share.
This commit is contained in:
Mikhail Golubev
2017-01-13 11:58:33 +03:00
parent 4e3322a0eb
commit 6838043503
2 changed files with 7 additions and 2 deletions
@@ -283,9 +283,12 @@ public class PyBlock implements ASTBlock {
}
if (childType == PyTokenTypes.RPAR) {
childIndent = Indent.getNoneIndent();
if (!hasHangingIndent(myNode.getPsi()) || settings.HANG_CLOSING_BRACKETS) {
if (!hasHangingIndent(myNode.getPsi())) {
childAlignment = getAlignmentForChildren();
}
else if (settings.HANG_CLOSING_BRACKETS) {
childIndent = Indent.getNormalIndent();
}
}
}
}
@@ -676,6 +676,8 @@ public class PyFormatterTest extends PyTestCase {
// PY-10182
public void testHangClosingParenthesisInFromImport() {
// Shouldn't affect the result
getPythonCodeStyleSettings().ALIGN_MULTILINE_IMPORTS = false;
getPythonCodeStyleSettings().HANG_CLOSING_BRACKETS = true;
doTest();
}
@@ -692,7 +694,7 @@ public class PyFormatterTest extends PyTestCase {
doTest();
}
// PY-10182
// PY-10182
public void testHangClosingParenthesisInListLiteral() {
getPythonCodeStyleSettings().HANG_CLOSING_BRACKETS = true;
doTest();