[java] TextBlockJoinLinesHandler: convert '\s' to ' ' when converting to regular string

GitOrigin-RevId: 5bcd1fb600f5d9a12286147582b4e70726c3835a
This commit is contained in:
Tagir Valeev
2024-06-13 14:35:00 +02:00
committed by intellij-monorepo-bot
parent 07406d6d08
commit 775db0701c
4 changed files with 18 additions and 1 deletions

View File

@@ -103,7 +103,12 @@ public final class TextBlockJoinLinesHandler implements JoinRawLinesHandlerDeleg
}
int nextI = PsiLiteralUtil.parseBackSlash(literal, i);
if (nextI != -1) {
if (sb != null) {
if (nextI == i + 1 && literal.charAt(nextI) == 's') {
if (sb == null) {
sb = new StringBuilder(literal.substring(3, i));
}
sb.append(' ');
} else if (sb != null) {
sb.append(literal, i + 1, nextI + 1);
}
//noinspection AssignmentToForLoopParameter

View File

@@ -0,0 +1,6 @@
class A {
void test() {
String s = STR."""<caret>
Hello\s""";
}
}

View File

@@ -0,0 +1,5 @@
class A {
void test() {
String s = STR."Hello ";
}
}

View File

@@ -315,6 +315,7 @@ public class JoinLinesTest extends LightJavaCodeInsightTestCase {
public void testJoinTextBlockSlashSFake() {doTest();}
public void testJoinTextBlockSlashS2() {doTest();}
public void testJoinTextBlockSlashSComplete() {doTest();}
public void testJoinTextBlockSlashSAtTheEnd() {doTest();}
public void testJoinStringTemplateBackSlash() {doTest();}
public void testJoinStringTemplateBackSlash2() {doTest();}