"Join lines" works incorrectly in case of line containing more than one string literal (KT-22374)
#KT-22374 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
cc346aef64
commit
7e417272b2
@@ -49,7 +49,9 @@ class JoinToStringTemplateHandler : JoinRawLinesHandlerDelegate {
|
|||||||
|
|
||||||
var rightText = ConvertToStringTemplateIntention.buildText(binaryExpr.right, false)
|
var rightText = ConvertToStringTemplateIntention.buildText(binaryExpr.right, false)
|
||||||
var left = binaryExpr.left
|
var left = binaryExpr.left
|
||||||
while (left is KtBinaryExpression && left.joinable() && left.parent.getLineCount() >= lineCount) {
|
while (left is KtBinaryExpression && left.joinable()) {
|
||||||
|
val leftLeft = (left as? KtBinaryExpression)?.left ?: break
|
||||||
|
if (leftLeft.lineCount() < lineCount) break
|
||||||
rightText = ConvertToStringTemplateIntention.buildText(left.right, false) + rightText
|
rightText = ConvertToStringTemplateIntention.buildText(left.right, false) + rightText
|
||||||
left = left.left
|
left = left.left
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun test() {
|
||||||
|
val s = "1" +
|
||||||
|
"2" +<caret>
|
||||||
|
"3"
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun test() {
|
||||||
|
val s = "1" +
|
||||||
|
"2<caret>3"
|
||||||
|
}
|
||||||
+6
@@ -458,5 +458,11 @@ public class JoinLinesTestGenerated extends AbstractJoinLinesTest {
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/joinLines/stringTemplate/threeLines.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/joinLines/stringTemplate/threeLines.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("threeLines2.kt")
|
||||||
|
public void testThreeLines2() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/joinLines/stringTemplate/threeLines2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user