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 all 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
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
}