Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes continuation indent in ktfmt default formatter #1562

Merged
merged 6 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
2 changes: 2 additions & 0 deletions plugin-maven/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).

## [Unreleased]
### Fixed
* Maven plugin with `ktfmt` default style uses correct continuation indent ([#1562](https://github.com/diffplug/spotless/pull/1562))
lonnelars marked this conversation as resolved.
Show resolved Hide resolved

## [2.32.0] - 2023-02-05
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import com.diffplug.spotless.maven.MavenIntegrationHarness;

import java.io.IOException;

class KtfmtTest extends MavenIntegrationHarness {
@Test
void testKtfmt() throws Exception {
Expand All @@ -36,6 +38,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
}