better formatting for generator expressions (PY-6219)

This commit is contained in:
Dmitry Jemerov
2012-04-03 16:56:17 +02:00
parent 44be38a21b
commit 55f1abbd99
4 changed files with 12 additions and 1 deletions
@@ -183,7 +183,8 @@ public class PyBlock implements ASTBlock {
childIndent = Indent.getNormalIndent();
}
}
else if (parentType == PyElementTypes.PARENTHESIZED_EXPRESSION && hasLineBreaksBefore(child, 1)) {
else if ((parentType == PyElementTypes.PARENTHESIZED_EXPRESSION || parentType == PyElementTypes.GENERATOR_EXPRESSION) &&
hasLineBreaksBefore(child, 1)) {
childIndent = Indent.getNormalIndent();
}
@@ -0,0 +1,3 @@
def dbl():
return (
(a, a) for a in [])
@@ -0,0 +1,3 @@
def dbl():
return (
(a, a) for a in [])
@@ -144,6 +144,10 @@ public class PyFormatterTest extends PyTestCase {
doTest();
}
public void testIndentInGenerator() { // PY-6219
doTest();
}
public void testPsiFormatting() { // IDEA-69724
String initial =
"def method_name(\n" +