Consider option about new line after opening brace in dicts when aligning closing one

Because this setting causes hanging indent to appear on reformat.
This commit is contained in:
Mikhail Golubev
2017-01-23 17:41:20 +03:00
parent c5a51bf665
commit 329c03abd9
4 changed files with 14 additions and 1 deletions
@@ -617,7 +617,8 @@ public class PyBlock implements ASTBlock {
myContext.getMode() == FormattingMode.ADJUST_INDENT) {
return true;
}
return !hasHangingIndent(myNode.getPsi());
return !hasHangingIndent(myNode.getPsi()) && !(myNode.getElementType() == PyElementTypes.DICT_LITERAL_EXPRESSION &&
myContext.getPySettings().DICT_NEW_LINE_AFTER_LEFT_BRACE);
}
if (myNode.getElementType() == PyElementTypes.ARGUMENT_LIST) {
if (!myContext.getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS || hasHangingIndent(myNode.getPsi())) {
@@ -0,0 +1,3 @@
d = {"foo": 1,
"bar": 2
}
@@ -0,0 +1,4 @@
d = {
"foo": 1,
"bar": 2
}
@@ -484,6 +484,11 @@ public class PyFormatterTest extends PyTestCase {
public void testAlignmentOfClosingBraceInDictLiteralWhenNoHangingIndent() {
doTest();
}
public void testNoAlignmentClosingBraceInDictLiteralWhenOpeningBraceIsForcedOnNewLine() {
getPythonCodeStyleSettings().DICT_NEW_LINE_AFTER_LEFT_BRACE = true;
doTest();
}
// PY-13004
public void testAlignmentOfClosingParenthesisOfArgumentListWhenNoHangingIndent() {