indent, rather than align, child expression of subscription expression (PY-8572)

This commit is contained in:
Dmitry Jemerov
2013-01-28 16:37:02 +01:00
parent 70949d0d97
commit 035efc6bba
4 changed files with 25 additions and 1 deletions
@@ -200,6 +200,12 @@ public class PyBlock implements ASTBlock {
childIndent = Indent.getNormalIndent();
}
}
else if (parentType == PyElementTypes.SUBSCRIPTION_EXPRESSION) {
PyExpression indexExpression = ((PySubscriptionExpression)_node.getPsi()).getIndexExpression();
if (indexExpression != null && child == indexExpression.getNode()) {
childIndent = Indent.getNormalIndent();
}
}
if (isAfterStatementList(child) && !hasLineBreaksBefore(child, 2)) { // maybe enter was pressed and cut us from a previous (nested) statement list
childIndent = Indent.getNormalIndent();
@@ -279,6 +285,9 @@ public class PyBlock implements ASTBlock {
if (_node.getElementType() == PyElementTypes.PARAMETER_LIST) {
return myContext.getSettings().ALIGN_MULTILINE_PARAMETERS;
}
if (_node.getElementType() == PyElementTypes.SUBSCRIPTION_EXPRESSION) {
return false;
}
if (child.getElementType() == PyTokenTypes.COMMA) {
return false;
}
@@ -0,0 +1,4 @@
if True:
if False:
if True:
returnData['error_text'] = "User with " + email_address + " email address is already part of " + company.name
@@ -0,0 +1,5 @@
if True:
if False:
if True:
returnData[
'error_text'] = "User with " + email_address + " email address is already part of " + company.name
@@ -248,7 +248,13 @@ public class PyFormatterTest extends PyTestCase {
settings().WRAP_LONG_LINES = false;
doTest();
}
public void testIndentInSlice() { // PY-8572
settings().RIGHT_MARGIN = 120;
settings().WRAP_LONG_LINES = false;
doTest();
}
private void doTest() {
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
ApplicationManager.getApplication().runWriteAction(new Runnable() {