mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-21823 Align bound and stride expressions inside slices
This commit is contained in:
@@ -327,6 +327,10 @@ public class PyBlock implements ASTBlock {
|
||||
childIndent = Indent.getNoneIndent();
|
||||
}
|
||||
}
|
||||
// Note that colons are aligned together with bounds and stride
|
||||
else if (myNode.getElementType() == PyElementTypes.SLICE_ITEM) {
|
||||
childAlignment = getChildAlignment();
|
||||
}
|
||||
else if (parentType == PyElementTypes.GENERATOR_EXPRESSION || parentType == PyElementTypes.PARENTHESIZED_EXPRESSION) {
|
||||
final boolean tupleOrGenerator = parentType == PyElementTypes.GENERATOR_EXPRESSION ||
|
||||
myNode.getPsi(PyParenthesizedExpression.class).getContainedExpression() instanceof PyTupleExpression;
|
||||
@@ -934,7 +938,7 @@ public class PyBlock implements ASTBlock {
|
||||
|
||||
@Nullable
|
||||
private Alignment getChildAlignment() {
|
||||
if (ourListElementTypes.contains(myNode.getElementType())) {
|
||||
if (ourListElementTypes.contains(myNode.getElementType()) || myNode.getElementType() == PyElementTypes.SLICE_ITEM) {
|
||||
if (isInControlStatement()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
xs1 = ys[42:
|
||||
5:
|
||||
-1]
|
||||
|
||||
xs2 = ys[:
|
||||
2:
|
||||
3]
|
||||
|
||||
xs3 = ys[::
|
||||
3]
|
||||
@@ -0,0 +1,10 @@
|
||||
xs1 = ys[42:
|
||||
5:
|
||||
-1]
|
||||
|
||||
xs2 = ys[:
|
||||
2:
|
||||
3]
|
||||
|
||||
xs3 = ys[::
|
||||
3]
|
||||
@@ -847,6 +847,11 @@ public class PyFormatterTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-21823
|
||||
public void testSliceAlignment() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVariableAnnotations() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON36, this::doTest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user