[java-completion] IDEA-356400 Join lines adds \n outside text block literal

GitOrigin-RevId: 8afe6a733da77bb78e42feec646437af62400d23
This commit is contained in:
Tagir Valeev
2024-07-18 14:03:53 +02:00
committed by intellij-monorepo-bot
parent d3a058c788
commit 097332e117
4 changed files with 15 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ public final class TextBlockJoinLinesHandler implements JoinRawLinesHandlerDeleg
!tokenType.equals(JavaTokenType.TEXT_BLOCK_TEMPLATE_MID)) {
return CANNOT_JOIN;
}
if (file.findElementAt(end) != token) return CANNOT_JOIN;
TextRange tokenRange = token.getTextRange();
int lineNumber = doc.getLineNumber(start);
boolean atStartLine = (tokenType.equals(JavaTokenType.TEXT_BLOCK_LITERAL) || tokenType.equals(JavaTokenType.TEXT_BLOCK_TEMPLATE_BEGIN))

View File

@@ -0,0 +1,7 @@
class X {
void x() {
System.out.println("""
some text"""<caret>
);
}
}

View File

@@ -0,0 +1,6 @@
class X {
void x() {
System.out.println("""
some text"""<caret>);
}
}

View File

@@ -318,6 +318,7 @@ public class JoinLinesTest extends LightJavaCodeInsightTestCase {
public void testJoinTextBlockSlashSAtTheEnd() {doTest();}
public void testJoinStringTemplateBackSlash() {doTest();}
public void testJoinStringTemplateBackSlash2() {doTest();}
public void testJoinOutsideOfTextBlock() { doTest(); }
private void doTest() {
doTest(".java");