Enable auto-indent in multiline strings when caret is before interpolation

#KT-17849 Fixed
This commit is contained in:
Nikolay Krasko
2017-05-18 15:41:46 +03:00
parent 251a0270a4
commit 14c343de35
4 changed files with 25 additions and 1 deletions
@@ -273,7 +273,7 @@ class KotlinMultilineStringEnterHandler : EnterHandlerDelegateAdapter() {
KtTokens.REGULAR_STRING_PART -> {
// Ok
}
KtTokens.CLOSING_QUOTE -> {
KtTokens.CLOSING_QUOTE, KtTokens.SHORT_TEMPLATE_ENTRY_START, KtTokens.LONG_TEMPLATE_ENTRY_START -> {
if (element.startOffset != offset) {
return null
}
@@ -0,0 +1,6 @@
val className = 1
val test = """<caret>${className}"""
//-----
val className = 1
val test = """
<caret>${className}""".trimIndent()
@@ -0,0 +1,6 @@
val className = 1
val test = """<caret>$className"""
//-----
val className = 1
val test = """
<caret>$className""".trimIndent()
@@ -104,12 +104,24 @@ public class MultiLineStringIndentTestGenerated extends AbstractMultiLineStringI
doTest(fileName);
}
@TestMetadata("enterBeforeLongEntryOneLine.kt")
public void testEnterBeforeLongEntryOneLine() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/enterHandler/multilineString/spaces/enterBeforeLongEntryOneLine.kt");
doTest(fileName);
}
@TestMetadata("enterBeforeMarginChar.kt")
public void testEnterBeforeMarginChar() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/enterHandler/multilineString/spaces/enterBeforeMarginChar.kt");
doTest(fileName);
}
@TestMetadata("enterBeforeShortEntryOneLine.kt")
public void testEnterBeforeShortEntryOneLine() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/enterHandler/multilineString/spaces/enterBeforeShortEntryOneLine.kt");
doTest(fileName);
}
@TestMetadata("enterInInfixMargin.kt")
public void testEnterInInfixMargin() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/enterHandler/multilineString/spaces/enterInInfixMargin.kt");