mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
PY-10182 Handle closing parenthesis in tuple literals
This commit is contained in:
@@ -315,7 +315,10 @@ public class PyBlock implements ASTBlock {
|
||||
}
|
||||
}
|
||||
else if (parentType == PyElementTypes.GENERATOR_EXPRESSION || parentType == PyElementTypes.PARENTHESIZED_EXPRESSION) {
|
||||
if (childType == PyTokenTypes.RPAR || !hasLineBreaksBeforeInSameParent(child, 1)) {
|
||||
final boolean insideTuple = parentType == PyElementTypes.PARENTHESIZED_EXPRESSION &&
|
||||
myNode.getPsi(PyParenthesizedExpression.class).getContainedExpression() instanceof PyTupleExpression;
|
||||
if ((childType == PyTokenTypes.RPAR && !(insideTuple && settings.HANG_CLOSING_BRACKETS)) ||
|
||||
!hasLineBreaksBeforeInSameParent(child, 1)) {
|
||||
childIndent = Indent.getNoneIndent();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
xs1 = [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
|
||||
xs2 = {
|
||||
1,
|
||||
2,
|
||||
3
|
||||
}
|
||||
|
||||
xs3 = {
|
||||
1: None,
|
||||
2: None,
|
||||
3: None,
|
||||
}
|
||||
|
||||
xs4 = (
|
||||
1,
|
||||
2,
|
||||
3
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
xs1 = [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
|
||||
xs2 = {
|
||||
1,
|
||||
2,
|
||||
3
|
||||
}
|
||||
|
||||
xs3 = {
|
||||
1: None,
|
||||
2: None,
|
||||
3: None,
|
||||
}
|
||||
|
||||
xs4 = (
|
||||
1,
|
||||
2,
|
||||
3
|
||||
)
|
||||
@@ -1,5 +0,0 @@
|
||||
xs = [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
@@ -1,5 +0,0 @@
|
||||
xs = [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
@@ -695,11 +695,10 @@ public class PyFormatterTest extends PyTestCase {
|
||||
}
|
||||
|
||||
// PY-10182
|
||||
public void testHangClosingParenthesisInListLiteral() {
|
||||
public void testHangClosingBracketsInCollectionLiterals() {
|
||||
getPythonCodeStyleSettings().HANG_CLOSING_BRACKETS = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testVariableAnnotations() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON36, this::doTest);
|
||||
|
||||
Reference in New Issue
Block a user