Don't merge two lines in formatter after line comment (KT-16032)
#KT-16032 Fixed
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.formatting.DependentSpacingRule.Anchor
|
||||
import com.intellij.formatting.DependentSpacingRule.Trigger
|
||||
import com.intellij.lang.ASTNode
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiComment
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import com.intellij.psi.tree.TokenSet
|
||||
@@ -80,10 +81,12 @@ class KotlinSpacingBuilder(val commonCodeStyleSettings: CommonCodeStyleSettings,
|
||||
|
||||
fun emptyLinesIfLineBreakInLeft(emptyLines: Int, numberOfLineFeedsOtherwise: Int = 1, numSpacesOtherwise: Int = 0) {
|
||||
newRule { parent: ASTBlock, left: ASTBlock, right: ASTBlock ->
|
||||
val lastChild = left.node?.psi?.lastChild
|
||||
val leftEndsWithComment = lastChild is PsiComment && lastChild.tokenType == KtTokens.EOL_COMMENT
|
||||
val dependentSpacingRule = DependentSpacingRule(Trigger.HAS_LINE_FEEDS).registerData(Anchor.MIN_LINE_FEEDS, emptyLines + 1)
|
||||
spacingBuilderUtil.createLineFeedDependentSpacing(numSpacesOtherwise,
|
||||
numSpacesOtherwise,
|
||||
numberOfLineFeedsOtherwise,
|
||||
if (leftEndsWithComment) Math.max(1, numberOfLineFeedsOtherwise) else numberOfLineFeedsOtherwise,
|
||||
commonCodeStyleSettings.KEEP_LINE_BREAKS,
|
||||
commonCodeStyleSettings.KEEP_BLANK_LINES_IN_DECLARATIONS,
|
||||
left.textRange,
|
||||
|
||||
Reference in New Issue
Block a user