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 (#530)

Fixes #518
  • Loading branch information
shashachu authored Jul 17, 2019
1 parent 579de38 commit fae5355
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 fae5355

Please sign in to comment.