Multiline string enter handler: do not insert 'trimIndent()' in const (KT-34785)
#KT-34785 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
ce0fb662c0
commit
58fb1dede3
@@ -358,7 +358,7 @@ class KotlinMultilineStringEnterHandler : EnterHandlerDelegateAdapter() {
|
||||
|
||||
fun insertTrimCall(document: Document, literal: KtStringTemplateExpression, marginChar: Char?) {
|
||||
if (hasTrimIndentCallInChain(literal) || getMarginCharFromTrimMarginCallsInChain(literal) != null) return
|
||||
if (literal.parents.any { it is KtAnnotationEntry }) return
|
||||
if (literal.parents.any { it is KtAnnotationEntry || (it as? KtProperty)?.hasModifier(KtTokens.CONST_KEYWORD) == true }) return
|
||||
|
||||
if (marginChar == null) {
|
||||
document.insertString(literal.textRange.endOffset, ".$TRIM_INDENT_CALL()")
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
object O {
|
||||
const val s = """<caret>"""
|
||||
}
|
||||
//-----
|
||||
object O {
|
||||
const val s = """
|
||||
<caret>
|
||||
"""
|
||||
}
|
||||
+5
@@ -220,6 +220,11 @@ public class MultiLineStringIndentTestGenerated extends AbstractMultiLineStringI
|
||||
runTest("idea/testData/editor/enterHandler/multilineString/spaces/noTrimIndentInAnnotations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noTrimIndentInConst.kt")
|
||||
public void testNoTrimIndentInConst() throws Exception {
|
||||
runTest("idea/testData/editor/enterHandler/multilineString/spaces/noTrimIndentInConst.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("restoreIndentFromEmptyLine.kt")
|
||||
public void testRestoreIndentFromEmptyLine() throws Exception {
|
||||
runTest("idea/testData/editor/enterHandler/multilineString/spaces/restoreIndentFromEmptyLine.kt");
|
||||
|
||||
Reference in New Issue
Block a user