mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-20633 Don't need to call reformat twice to move right parenthesis in from imports sometimes
This commit is contained in:
@@ -295,7 +295,8 @@ public class PyBlock implements ASTBlock {
|
||||
}
|
||||
if (childType == PyTokenTypes.RPAR) {
|
||||
childIndent = Indent.getNoneIndent();
|
||||
if (!hasHangingIndent(myNode.getPsi())) {
|
||||
// Don't have hanging indent and is not going to have it due to the setting about opening parenthesis
|
||||
if (!hasHangingIndent(myNode.getPsi()) && !settings.FROM_IMPORT_NEW_LINE_AFTER_LEFT_PARENTHESIS) {
|
||||
childAlignment = getAlignmentForChildren();
|
||||
}
|
||||
else if (settings.HANG_CLOSING_BRACKETS) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
from module import (foo, bar)
|
||||
from module import (foo, bar,)
|
||||
from module import (foo, bar, baz, quux)
|
||||
from module import (foo,
|
||||
bar)
|
||||
from module import (foo,
|
||||
bar,
|
||||
)
|
||||
from module import (
|
||||
foo,
|
||||
bar)
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
from module import (foo, bar)
|
||||
from module import (foo, bar, )
|
||||
from module import (
|
||||
foo, bar, baz, quux
|
||||
)
|
||||
from module import (
|
||||
foo,
|
||||
bar
|
||||
)
|
||||
from module import (
|
||||
foo,
|
||||
bar,
|
||||
)
|
||||
from module import (
|
||||
foo,
|
||||
bar
|
||||
)
|
||||
@@ -2,15 +2,15 @@ from module import (foo, bar)
|
||||
from module import (foo, bar, )
|
||||
from module import (
|
||||
foo, bar, baz, quux
|
||||
)
|
||||
)
|
||||
from module import (
|
||||
foo,
|
||||
bar
|
||||
)
|
||||
)
|
||||
from module import (
|
||||
foo,
|
||||
bar,
|
||||
)
|
||||
)
|
||||
from module import (
|
||||
foo,
|
||||
bar
|
||||
|
||||
@@ -741,7 +741,6 @@ public class PyFormatterTest extends PyTestCase {
|
||||
}
|
||||
|
||||
// PY-20633
|
||||
// XXX causes jumping closing parenthesis, because of the hanging indent detection
|
||||
public void testFromImportParenthesesPlacement() {
|
||||
getPythonCodeStyleSettings().FROM_IMPORT_NEW_LINE_AFTER_LEFT_PARENTHESIS = true;
|
||||
getPythonCodeStyleSettings().FROM_IMPORT_NEW_LINE_BEFORE_RIGHT_PARENTHESIS = true;
|
||||
@@ -749,6 +748,16 @@ public class PyFormatterTest extends PyTestCase {
|
||||
getCodeStyleSettings().setRightMargin(PythonLanguage.INSTANCE, 35);
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-20633
|
||||
public void testFromImportParenthesesPlacementHangClosingParenthesis() {
|
||||
getPythonCodeStyleSettings().FROM_IMPORT_NEW_LINE_AFTER_LEFT_PARENTHESIS = true;
|
||||
getPythonCodeStyleSettings().FROM_IMPORT_NEW_LINE_BEFORE_RIGHT_PARENTHESIS = true;
|
||||
getPythonCodeStyleSettings().HANG_CLOSING_BRACKETS = true;
|
||||
getCommonCodeStyleSettings().SPACE_AFTER_COLON = true;
|
||||
getCodeStyleSettings().setRightMargin(PythonLanguage.INSTANCE, 35);
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVariableAnnotations() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON36, this::doTest);
|
||||
|
||||
Reference in New Issue
Block a user