Skip to content

Commit

Permalink
fixes continuation indent in ktfmt default formatter (#1562 from lonn…
Browse files Browse the repository at this point in the history
…elars/main)
  • Loading branch information
nedtwigg committed Feb 10, 2023
2 parents f53ded7 + 878a511 commit fc3f6ff
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (

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

## [2.34.1] - 2023-02-05
### Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 DiffPlug
* Copyright 2022-2023 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -78,7 +78,7 @@ private FormattingOptions createFormattingOptions() {
formattingOptions.getStyle(),
ktfmtFormattingOptions.getMaxWidth().orElse(formattingOptions.getMaxWidth()),
ktfmtFormattingOptions.getBlockIndent().orElse(formattingOptions.getBlockIndent()),
ktfmtFormattingOptions.getContinuationIndent().orElse(formattingOptions.getBlockIndent()),
ktfmtFormattingOptions.getContinuationIndent().orElse(formattingOptions.getContinuationIndent()),
ktfmtFormattingOptions.getRemoveUnusedImport().orElse(formattingOptions.getRemoveUnusedImports()),
formattingOptions.getDebuggingPrintOpsAfterFormatting());
}
Expand Down
4 changes: 3 additions & 1 deletion plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (

## [Unreleased]
### Added
* CleanThat Java Refactorer ([#1560](https://github.com/diffplug/spotless/pull/1560))
* CleanThat Java Refactorer. ([#1560](https://github.com/diffplug/spotless/pull/1560))
### Fixed
* `ktfmt` default style uses correct continuation indent. ([#1562](https://github.com/diffplug/spotless/pull/1562))

## [6.14.1] - 2023-02-05
### Fixed
Expand Down
4 changes: 3 additions & 1 deletion plugin-maven/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (

## [Unreleased]
### Added
* CleanThat Java Refactorer ([#1560](https://github.com/diffplug/spotless/pull/1560))
* CleanThat Java Refactorer. ([#1560](https://github.com/diffplug/spotless/pull/1560))
### Fixed
* `ktfmt` default style uses correct continuation indent. ([#1562](https://github.com/diffplug/spotless/pull/1562))

## [2.32.0] - 2023-02-05
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ void testKtfmt() throws Exception {
assertFile(path2).sameAsResource("kotlin/ktfmt/basic.clean");
}

@Test
void testContinuation() throws Exception {
writePomWithKotlinSteps("<ktfmt/>");

setFile("src/main/kotlin/main.kt").toResource("kotlin/ktfmt/continuation.dirty");
mavenRunner().withArguments("spotless:apply").runNoError();
assertFile("src/main/kotlin/main.kt").sameAsResource("kotlin/ktfmt/continuation.clean");
}

@Test
void testKtfmtStyle() throws Exception {
writePomWithKotlinSteps("<ktfmt><style>DROPBOX</style></ktfmt>");
Expand Down
6 changes: 6 additions & 0 deletions testlib/src/main/resources/kotlin/ktfmt/continuation.clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fun myFunction() {
val location =
restTemplate.postForLocation(
"/v1/my-api", mapOf("name" to "some-name", "url" to "https://www.google.com"))
return location
}
4 changes: 4 additions & 0 deletions testlib/src/main/resources/kotlin/ktfmt/continuation.dirty
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fun myFunction() {
val location = restTemplate.postForLocation("/v1/my-api", mapOf("name" to "some-name", "url" to "https://www.google.com"))
return location
}

0 comments on commit fc3f6ff

Please sign in to comment.