Skip to content

Commit

Permalink
Fixing issue where ktlint would erroneously want to insert a newline …
Browse files Browse the repository at this point in the history
…if parameter comments were used

Fixes pinterest#433
  • Loading branch information
shashachu committed May 22, 2019
1 parent cc6c59b commit 9dd6b69
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class IndentationRule : Rule("indent"), Rule.Modifier.RestrictToRootLast {
) {
return
}
if (!node.nextCodeLeaf()?.prevLeaf().isWhiteSpaceWithNewline() &&
if (!node.nextCodeLeaf()?.prevLeaf { !it.isPartOfComment() && it.textLength > 0 }.isWhiteSpaceWithNewline() &&
// IDEA quirk:
// if (true &&
// true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,22 @@ class IndentationRuleTest {
).isEmpty()
}

@Test(description = "https://github.com/pinterest/ktlint/issues/433")
fun testLintParameterListWithComments() {
assertThat(
IndentationRule().lint(
"""
fun main() {
foo(
/*param1=*/param1,
/*param2=*/param2
)
}
""".trimIndent()
)
).isEmpty()
}

@Test
fun testUnexpectedTabCharacter() {
val ktScript = "fun main() {\n\t\treturn 0\n\t}"
Expand Down

0 comments on commit 9dd6b69

Please sign in to comment.