Skip to content

Commit

Permalink
Fixing bug with improper indentation for enums with multi-line initia…
Browse files Browse the repository at this point in the history
…lizers

Fixes pinterest#518
  • Loading branch information
shashachu committed Jul 16, 2019
1 parent f024d20 commit 9c694c6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,11 @@ class IndentationRule : Rule("indent"), Rule.Modifier.RestrictToRootLast {
}

private fun adjustExpectedIndentInsideSuperTypeCall(n: ASTNode, ctx: IndentContext) {
// Don't adjust indents for initializer lists
if (n.treeParent?.elementType != SUPER_TYPE_LIST) {
return
}

if (
// n.treePrev == null &&
// n.treeParent.elementType == SUPER_TYPE_LIST &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,15 @@ class AndroidModuleDependency()
class AndroidModuleDependency()
: ModuleDependency(name, methodToCall, method),
ModuleDependency(name, methodToCall, method)

// https://github.com/pinterest/ktlint/issues/518
enum class Color(val displayName: String, val value: Int) {
RED(
displayName = "Red",
value = 1
),
BLUE(
displayName = "Blue",
value = 2
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@ class AndroidModuleDependency()
class AndroidModuleDependency()
: ModuleDependency(name, methodToCall, method),
ModuleDependency(name, methodToCall, method)

// https://github.com/pinterest/ktlint/issues/518
enum class Color(val displayName: String, val value: Int) {
RED(
displayName = "Red",
value = 1
),
BLUE(
displayName = "Blue",
value = 2
);
}

0 comments on commit 9c694c6

Please sign in to comment.