Fix indent in parenthesized expression in indenting statement (PY-11868).
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 22 Jan 2014 16:20:44 +0000 (17:20 +0100)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 22 Jan 2014 16:20:44 +0000 (17:20 +0100)
python/src/com/jetbrains/python/formatter/PyBlock.java
python/testData/formatter/continuationIndentInIndentingStatement2.py [new file with mode: 0644]
python/testData/formatter/continuationIndentInIndentingStatement2_after.py [new file with mode: 0644]
python/testSrc/com/jetbrains/python/PyFormatterTest.java

index 8afd35e009f2966eaf8ffaa4cdb325f61a888873..1d5a6e104748e2285ba6007ed7f458f0a2922c97 100644 (file)
@@ -238,7 +238,7 @@ public class PyBlock implements ASTBlock {
         childIndent = Indent.getNoneIndent();
       }
       else {
-        childIndent = Indent.getNormalIndent();
+        childIndent = isIndentNext(child) ? Indent.getContinuationIndent() : Indent.getNormalIndent();
       }
     }
     else if (parentType == PyElementTypes.SUBSCRIPTION_EXPRESSION) {
diff --git a/python/testData/formatter/continuationIndentInIndentingStatement2.py b/python/testData/formatter/continuationIndentInIndentingStatement2.py
new file mode 100644 (file)
index 0000000..63957fb
--- /dev/null
@@ -0,0 +1,4 @@
+def f(value, value1, value2):
+    if value in (
+        value1, value2) or value == 0:   # <- missing continuation indent here
+        return False
\ No newline at end of file
diff --git a/python/testData/formatter/continuationIndentInIndentingStatement2_after.py b/python/testData/formatter/continuationIndentInIndentingStatement2_after.py
new file mode 100644 (file)
index 0000000..703b4ae
--- /dev/null
@@ -0,0 +1,4 @@
+def f(value, value1, value2):
+    if value in (
+            value1, value2) or value == 0:   # <- missing continuation indent here
+        return False
\ No newline at end of file
index b745701d290d984acfe204bbd0df05844762b75c..ef7375ae72198ff959b87f3781a1f71abfad21f0 100644 (file)
@@ -207,6 +207,10 @@ public class PyFormatterTest extends PyTestCase {
     doTest();
   }
 
+  public void testContinuationIndentInIndentingStatement2() { // PY-11868
+    doTest();
+  }
+
   public void testBlankLineAfterDecorator() {
     doTest();
   }