mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
nicer formatting for dict literals (PY-1461)
This commit is contained in:
@@ -116,7 +116,7 @@ public class PyBlock implements ASTBlock {
|
||||
}
|
||||
if (ourListElementTypes.contains(parentType)) {
|
||||
wrap = Wrap.createWrap(WrapType.NORMAL, true);
|
||||
if (!PyTokenTypes.OPEN_BRACES.contains(childType)) {
|
||||
if (!PyTokenTypes.OPEN_BRACES.contains(childType) && !PyTokenTypes.CLOSE_BRACES.contains(childType)) {
|
||||
childAlignment = _childListAlignment;
|
||||
}
|
||||
}
|
||||
@@ -136,6 +136,14 @@ public class PyBlock implements ASTBlock {
|
||||
childIndent = Indent.getContinuationIndent();
|
||||
}
|
||||
}
|
||||
else if (parentType == PyElementTypes.DICT_LITERAL_EXPRESSION) {
|
||||
if (childType == PyTokenTypes.RBRACE) {
|
||||
childIndent = Indent.getNoneIndent();
|
||||
}
|
||||
else {
|
||||
childIndent = Indent.getNormalIndent();
|
||||
}
|
||||
}
|
||||
try { // maybe enter was pressed and cut us from a previous (nested) statement list
|
||||
PsiElement prev = sure(child.getPsi().getPrevSibling());
|
||||
sure(prev instanceof PyStatement);
|
||||
|
||||
7
python/testData/formatter/dictLiteral.py
Normal file
7
python/testData/formatter/dictLiteral.py
Normal file
@@ -0,0 +1,7 @@
|
||||
map = {
|
||||
'node': {
|
||||
'key1': 'key1value',
|
||||
'key2': 'key2value',
|
||||
'key3': 'key3value'
|
||||
}
|
||||
}
|
||||
7
python/testData/formatter/dictLiteral_after.py
Normal file
7
python/testData/formatter/dictLiteral_after.py
Normal file
@@ -0,0 +1,7 @@
|
||||
map = {
|
||||
'node': {
|
||||
'key1': 'key1value',
|
||||
'key2': 'key2value',
|
||||
'key3': 'key3value'
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,10 @@ public class PyFormatterTest extends PyLightFixtureTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testDictLiteral() { // PY-1461
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
|
||||
Reference in New Issue
Block a user