diff --git a/python/src/com/jetbrains/python/formatter/PyBlock.java b/python/src/com/jetbrains/python/formatter/PyBlock.java index 228a0870ce0d..018fc36c278e 100644 --- a/python/src/com/jetbrains/python/formatter/PyBlock.java +++ b/python/src/com/jetbrains/python/formatter/PyBlock.java @@ -185,7 +185,7 @@ public class PyBlock implements ASTBlock { IElementType type1 = childNode1.getElementType(); IElementType type2 = childNode2.getElementType(); - if (type1 == PyElementTypes.FUNCTION_DECLARATION) { + if (type1 == PyElementTypes.FUNCTION_DECLARATION || (type2 == PyElementTypes.FUNCTION_DECLARATION && type1 == PyElementTypes.CLASS_DECLARATION)) { int blankLines = mySettings.BLANK_LINES_AROUND_METHOD + 1; return Spacing.createSpacing(0, 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS); } diff --git a/python/testData/formatter/blankLineBetweenMethods.py b/python/testData/formatter/blankLineBetweenMethods.py index 54dab3e9134c..2f18aaa72111 100644 --- a/python/testData/formatter/blankLineBetweenMethods.py +++ b/python/testData/formatter/blankLineBetweenMethods.py @@ -1,3 +1,5 @@ +class C: + pass def foo(): pass def bar(): diff --git a/python/testData/formatter/blankLineBetweenMethods_after.py b/python/testData/formatter/blankLineBetweenMethods_after.py index ccd6736bb022..89a633f6165e 100644 --- a/python/testData/formatter/blankLineBetweenMethods_after.py +++ b/python/testData/formatter/blankLineBetweenMethods_after.py @@ -1,3 +1,6 @@ +class C: + pass + def foo(): pass diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java index e1e4aac7706c..7681cdd2313b 100644 --- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java +++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java @@ -9,6 +9,10 @@ import com.jetbrains.python.fixtures.PyLightFixtureTestCase; */ public class PyFormatterTest extends PyLightFixtureTestCase { public void testBlankLineBetweenMethods() throws Exception { + doTest(); + } + + private void doTest() throws Exception { myFixture.configureByFile("formatter/" + getTestName(true) + ".py"); ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() {