mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix alignment after first argument in call (PY-6360)
This commit is contained in:
@@ -55,7 +55,7 @@ public class PyPsiUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static ASTNode getNextComma(ASTNode after) {
|
||||
public static ASTNode getNextComma(ASTNode after) {
|
||||
ASTNode node = after;
|
||||
PyElementType comma = PyTokenTypes.COMMA;
|
||||
do {
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.jetbrains.python.PyElementTypes;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.PythonDialectsTokenSetProvider;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -238,7 +239,11 @@ public class PyBlock implements ASTBlock {
|
||||
return false;
|
||||
}
|
||||
PyArgumentList argList = (PyArgumentList)_node.getPsi();
|
||||
return argList != null && argList.getArguments().length > 1;
|
||||
if (argList != null) {
|
||||
PyExpression[] arguments = argList.getArguments();
|
||||
return arguments.length > 1 || (arguments.length == 1 && PyPsiUtils.getNextComma(arguments[0].getNode()) != null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (_node.getElementType() == PyElementTypes.PARAMETER_LIST) {
|
||||
return mySettings.ALIGN_MULTILINE_PARAMETERS;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.jetbrains.python;
|
||||
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
|
||||
/**
|
||||
@@ -295,6 +296,13 @@ public class PyIndentTest extends PyTestCase {
|
||||
"]");
|
||||
}
|
||||
|
||||
public void testAlignInCall() { // PY-6360
|
||||
CodeStyleSettingsManager.getInstance().getSettings(myFixture.getProject()).ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
doTest("list(a,<caret>)",
|
||||
"list(a,\n" +
|
||||
" <caret>)");
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: formatter core problem?
|
||||
public void testAlignListBeforeEquals() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user