diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt index 8e80ac294d7..14441d6079a 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -219,6 +219,9 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing afterInside(ANNOTATION_ENTRY, ANNOTATED_EXPRESSION).spaces(1) + before(SEMICOLON).spaces(0) + after(SEMICOLON).spaces(1) + val TYPE_COLON_ELEMENTS = TokenSet.create(PROPERTY, FUN, VALUE_PARAMETER, DESTRUCTURING_DECLARATION_ENTRY, FUNCTION_LITERAL) beforeInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_BEFORE_TYPE_COLON) } afterInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_AFTER_TYPE_COLON) } diff --git a/idea/testData/formatter/Semicolon.after.kt b/idea/testData/formatter/Semicolon.after.kt new file mode 100644 index 00000000000..34f18f48f8c --- /dev/null +++ b/idea/testData/formatter/Semicolon.after.kt @@ -0,0 +1,3 @@ +fun foo() { + ""; "" +} \ No newline at end of file diff --git a/idea/testData/formatter/Semicolon.kt b/idea/testData/formatter/Semicolon.kt new file mode 100644 index 00000000000..a10d7b66b0f --- /dev/null +++ b/idea/testData/formatter/Semicolon.kt @@ -0,0 +1,3 @@ +fun foo() { + "" ; "" +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java index 981106d5189..8259ece326b 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java @@ -517,6 +517,12 @@ public class FormatterTestGenerated extends AbstractFormatterTest { doTest(fileName); } + @TestMetadata("Semicolon.after.kt") + public void testSemicolon() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/Semicolon.after.kt"); + doTest(fileName); + } + @TestMetadata("SingleLineFunctionLiteral.after.kt") public void testSingleLineFunctionLiteral() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/SingleLineFunctionLiteral.after.kt");