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

Trailing space(s) on empty line affects start of comments. Ktlint deletes both lines' indentation #1334

Closed
carstenhag opened this issue Jan 11, 2022 · 1 comment · Fixed by #1345

Comments

@carstenhag
Copy link

carstenhag commented Jan 11, 2022

Expected Behavior

Ktlint deletes 4 spaces, leaves the 1st multiline comment untouched

Observed Behavior

Ktlint deletes 4 spaces and also the indentation of the 1st multiline comment line

Steps to Reproduce

· = space

interface IKtLintTest {
····/**
·····* Something 1
·····*/
····val test: String
····
····/**
·····* Something 2
·····*/
····val authenticationState: AuthState?

····/**
·····* Something 3
·····*/
····val test: String

}

.editorconfig

[*.{kt,kts}]
indent_size=4
insert_final_newline=true

-->

interface IKtLintTest {

····/**
·····* Something 1
·····*/
····val test: String

/**
·····* Something 2
·····*/
····val authenticationState: AuthState?

····/**
·····* Something 3
·····*/
····val test: String
}

If I manually remove the 4 spaces at the empty line, then run ktlint again, it doesn't break the multiline comment anymore.

Your Environment

  • Version of ktlint used: 0.42.1
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): https://github.com/pinterest/ktlint#without-a-plugin (custom gradle task)
  • Version of Gradle used (if applicable):
  • Operating System and version: macOS 11.5.2
@carstenhag carstenhag changed the title Trailing space(s) on empty line affects start of multiline comment. Ktlint deletes both lines' indentation Trailing space(s) on empty line affects start of comments. Ktlint deletes both lines' indentation Jan 11, 2022
@carstenhag
Copy link
Author

Also applies to single-line comments:
Bildschirmfoto 2022-01-11 um 11 03 17

paul-dingemans pushed a commit to paul-dingemans/ktlint that referenced this issue Jan 23, 2022
In most cases this is probably fixed by the indent rule but at least not
when next line contains a KDoc

Closes pinterest#1334
@paul-dingemans paul-dingemans self-assigned this Jan 27, 2022
shashachu added a commit that referenced this issue Feb 8, 2022
In most cases this is probably fixed by the indent rule but at least not
when next line contains a KDoc

Closes #1334

Co-authored-by: Paul Dingemans <[email protected]>
Co-authored-by: Sha Sha Chu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants