PY-20392 Put space after trailing comma in dict literals if SPACE_AFTER_COMMA is enabled

This commit is contained in:
Mikhail Golubev
2016-08-24 22:18:16 +03:00
parent 7ae5998264
commit 2d8fe72a93
4 changed files with 8 additions and 0 deletions

View File

@@ -99,6 +99,7 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
.afterInside(RARROW, ANNOTATION).spaces(1)
.between(allButLambda(), PARAMETER_LIST).spaceIf(commonSettings.SPACE_BEFORE_METHOD_PARENTHESES)
.betweenInside(COMMA, RBRACE, DICT_LITERAL_EXPRESSION).spaceIf(commonSettings.SPACE_AFTER_COMMA, pySettings.DICT_NEW_LINE_BEFORE_RIGHT_BRACE)
.afterInside(LBRACE, DICT_LITERAL_EXPRESSION).spaceIf(pySettings.SPACE_WITHIN_BRACES, pySettings.DICT_NEW_LINE_AFTER_LEFT_BRACE)
.beforeInside(RBRACE, DICT_LITERAL_EXPRESSION).spaceIf(pySettings.SPACE_WITHIN_BRACES, pySettings.DICT_NEW_LINE_BEFORE_RIGHT_BRACE)

View File

@@ -0,0 +1 @@
dict = { 1: 'a', 2: 'b', 3: 'c',}

View File

@@ -0,0 +1 @@
dict = {1: 'a', 2: 'b', 3: 'c', }

View File

@@ -660,4 +660,9 @@ public class PyFormatterTest extends PyTestCase {
getPythonCodeStyleSettings().SPACE_AROUND_POWER_OPERATOR = false;
doTest();
}
// PY-20392
public void testSpaceAfterTrailingCommaInDictLiterals() {
doTest();
}
}