mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
tweak logic for detecting incomplete formatter blocks (PY-3572)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user