Skip to content

Commit fc3f6ff

Browse files
authored
fixes continuation indent in ktfmt default formatter (#1562 from lonnelars/main)
2 parents f53ded7 + 878a511 commit fc3f6ff

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

CHANGES.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1111

1212
## [Unreleased]
1313
### Added
14-
* CleanThat Java Refactorer ([#???](https://github.com/diffplug/spotless/pull/???))
14+
* CleanThat Java Refactorer. ([#1560](https://github.com/diffplug/spotless/pull/1560))
15+
### Fixed
16+
* `ktfmt` default style uses correct continuation indent. ([#1562](https://github.com/diffplug/spotless/pull/1562))
1517

1618
## [2.34.1] - 2023-02-05
1719
### Changes

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 DiffPlug
2+
* Copyright 2022-2023 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -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-gradle/CHANGES.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
44

55
## [Unreleased]
66
### Added
7-
* CleanThat Java Refactorer ([#1560](https://github.com/diffplug/spotless/pull/1560))
7+
* CleanThat Java Refactorer. ([#1560](https://github.com/diffplug/spotless/pull/1560))
8+
### Fixed
9+
* `ktfmt` default style uses correct continuation indent. ([#1562](https://github.com/diffplug/spotless/pull/1562))
810

911
## [6.14.1] - 2023-02-05
1012
### Fixed

plugin-maven/CHANGES.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
44

55
## [Unreleased]
66
### Added
7-
* CleanThat Java Refactorer ([#1560](https://github.com/diffplug/spotless/pull/1560))
7+
* CleanThat Java Refactorer. ([#1560](https://github.com/diffplug/spotless/pull/1560))
8+
### Fixed
9+
* `ktfmt` default style uses correct continuation indent. ([#1562](https://github.com/diffplug/spotless/pull/1562))
810

911
## [2.32.0] - 2023-02-05
1012
### Added

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

+9
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ void testKtfmt() throws Exception {
3636
assertFile(path2).sameAsResource("kotlin/ktfmt/basic.clean");
3737
}
3838

39+
@Test
40+
void testContinuation() throws Exception {
41+
writePomWithKotlinSteps("<ktfmt/>");
42+
43+
setFile("src/main/kotlin/main.kt").toResource("kotlin/ktfmt/continuation.dirty");
44+
mavenRunner().withArguments("spotless:apply").runNoError();
45+
assertFile("src/main/kotlin/main.kt").sameAsResource("kotlin/ktfmt/continuation.clean");
46+
}
47+
3948
@Test
4049
void testKtfmtStyle() throws Exception {
4150
writePomWithKotlinSteps("<ktfmt><style>DROPBOX</style></ktfmt>");
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+
}
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)