diff --git a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java index da86dc41a54b..0ac16716b9c7 100644 --- a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java +++ b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java @@ -105,9 +105,12 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C .around(BITWISE_OPERATIONS).spaceIf(commonSettings.SPACE_AROUND_BITWISE_OPERATORS) .around(EQUALITY_OPERATIONS).spaceIf(commonSettings.SPACE_AROUND_EQUALITY_OPERATORS) .around(RELATIONAL_OPERATIONS).spaceIf(commonSettings.SPACE_AROUND_RELATIONAL_OPERATORS) - .around(IN_KEYWORD).spaces(1); + .around(SINGLE_SPACE_KEYWORDS).spaces(1); } + // should be all keywords? + private static final TokenSet SINGLE_SPACE_KEYWORDS = TokenSet.create(IN_KEYWORD, AND_KEYWORD, OR_KEYWORD, IS_KEYWORD); + private static TokenSet allButLambda() { final PythonLanguage pythonLanguage = PythonLanguage.getInstance(); return TokenSet.create(IElementType.enumerate(new IElementType.Predicate() { diff --git a/python/testData/formatter/spaceAroundKeywords.py b/python/testData/formatter/spaceAroundKeywords.py new file mode 100644 index 000000000000..ef0d0922136f --- /dev/null +++ b/python/testData/formatter/spaceAroundKeywords.py @@ -0,0 +1 @@ +True and False diff --git a/python/testData/formatter/spaceAroundKeywords_after.py b/python/testData/formatter/spaceAroundKeywords_after.py new file mode 100644 index 000000000000..a61962eda0cf --- /dev/null +++ b/python/testData/formatter/spaceAroundKeywords_after.py @@ -0,0 +1 @@ +True and False diff --git a/python/testSrc/com/jetbrains/python/PyFormatterTest.java b/python/testSrc/com/jetbrains/python/PyFormatterTest.java index 0e9e2e626c45..91cae9e3a812 100644 --- a/python/testSrc/com/jetbrains/python/PyFormatterTest.java +++ b/python/testSrc/com/jetbrains/python/PyFormatterTest.java @@ -183,6 +183,10 @@ public class PyFormatterTest extends PyTestCase { doTest(); } + public void testSpaceAroundKeywords() { + doTest(); + } + public void testPsiFormatting() { // IDEA-69724 String initial = "def method_name(\n" +