tweak logic for detecting incomplete formatter blocks (PY-3572)

This commit is contained in:
Dmitry Jemerov
2011-05-18 16:25:05 +02:00
parent c12957e980
commit a2465ccf22
2 changed files with 25 additions and 0 deletions
@@ -670,6 +670,15 @@ public class PyBlock implements ASTBlock {
}
public boolean isIncomplete() {
// if there's something following us, we're not incomplete
PsiElement element = _node.getPsi().getNextSibling();
while (element instanceof PsiWhiteSpace) {
element = element.getNextSibling();
}
if (element != null) {
return false;
}
ASTNode lastChild = getLastNonSpaceChild(_node, false);
if (lastChild != null && lastChild.getElementType() == PyElementTypes.STATEMENT_LIST) {
// only multiline statement lists are considered incomplete
@@ -249,6 +249,22 @@ public class PyIndentTest extends PyLightFixtureTestCase {
" <caret>\n");
}
public void testIndentAfterModuleLevelStatement() { // PY-3572
doTest("def a(var):\n" +
" if var == 'default':\n" +
" pass\n" +
"\n" +
"b = 1<caret>\n" +
"",
"def a(var):\n" +
" if var == 'default':\n" +
" pass\n" +
"\n" +
"b = 1\n" +
"<caret>\n" +
"");
}
/*
TODO: formatter core problem?
public void testAlignListBeforeEquals() throws Exception {