Skip to content

Commit 4f62769

Browse files
committed
fixes continuation indent in ktfmt default formatter
1 parent 3226d2b commit 4f62769

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

lib/src/ktfmt/java/com/diffplug/spotless/glue/ktfmt/KtfmtFormatterFunc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private FormattingOptions createFormattingOptions() {
7878
formattingOptions.getStyle(),
7979
ktfmtFormattingOptions.getMaxWidth().orElse(formattingOptions.getMaxWidth()),
8080
ktfmtFormattingOptions.getBlockIndent().orElse(formattingOptions.getBlockIndent()),
81-
ktfmtFormattingOptions.getContinuationIndent().orElse(formattingOptions.getBlockIndent()),
81+
ktfmtFormattingOptions.getContinuationIndent().orElse(formattingOptions.getContinuationIndent()),
8282
ktfmtFormattingOptions.getRemoveUnusedImport().orElse(formattingOptions.getRemoveUnusedImports()),
8383
formattingOptions.getDebuggingPrintOpsAfterFormatting());
8484
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/KtfmtTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
import com.diffplug.spotless.maven.MavenIntegrationHarness;
2121

22+
import java.io.IOException;
23+
2224
class KtfmtTest extends MavenIntegrationHarness {
2325
@Test
2426
void testKtfmt() throws Exception {
@@ -36,6 +38,15 @@ void testKtfmt() throws Exception {
3638
assertFile(path2).sameAsResource("kotlin/ktfmt/basic.clean");
3739
}
3840

41+
@Test
42+
void testContinuation() throws Exception {
43+
writePomWithKotlinSteps("<ktfmt/>");
44+
45+
setFile("src/main/kotlin/main.kt").toResource("kotlin/ktfmt/continuation.dirty");
46+
mavenRunner().withArguments("spotless:apply").runNoError();
47+
assertFile("src/main/kotlin/main.kt").sameAsResource("kotlin/ktfmt/continuation.clean");
48+
}
49+
3950
@Test
4051
void testKtfmtStyle() throws Exception {
4152
writePomWithKotlinSteps("<ktfmt><style>DROPBOX</style></ktfmt>");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fun myFunction() {
2+
val location =
3+
restTemplate.postForLocation(
4+
"/v1/my-api", mapOf("name" to "some-name", "url" to "https://www.google.com"))
5+
return location
6+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fun myFunction() {
2+
val location = restTemplate.postForLocation("/v1/my-api", mapOf("name" to "some-name", "url" to "https://www.google.com"))
3+
return location
4+
}

0 commit comments

Comments
 (0)