mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
[java] TextBlockJoinLinesHandler: fix end offset when converting to a regular literal (IDEA-349062)
GitOrigin-RevId: 752ffd98eefb9d7634a0bd3f78f9a47cb51ba945
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b3efd6516e
commit
eadfa417ab
+5
-4
@@ -56,16 +56,17 @@ public final class TextBlockJoinLinesHandler implements JoinRawLinesHandlerDeleg
|
||||
boolean fromStartTillEnd = atStartLine && tokenType.equals(JavaTokenType.TEXT_BLOCK_LITERAL) &&
|
||||
doc.getLineNumber(tokenRange.getEndOffset()) == lineNumber + 1 &&
|
||||
token.getText().endsWith("\"\"\"");
|
||||
int endOffset = tokenRange.getEndOffset();
|
||||
if (singleSlash || atEmptyStartLine) {
|
||||
doc.deleteString(start, end);
|
||||
end = start;
|
||||
endOffset += start - end;
|
||||
} else {
|
||||
doc.replaceString(start, end, "\\n");
|
||||
end = start + 2;
|
||||
endOffset += start - end + 2;
|
||||
}
|
||||
if (fromStartTillEnd) {
|
||||
doc.replaceString(tokenRange.getStartOffset(), end + 3,
|
||||
convertToRegular(doc.getText().substring(tokenRange.getStartOffset(), end + 3)));
|
||||
doc.replaceString(tokenRange.getStartOffset(), endOffset,
|
||||
convertToRegular(doc.getText().substring(tokenRange.getStartOffset(), endOffset)));
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
void test() {
|
||||
String s = <selection>"""
|
||||
Line1
|
||||
Line2"""</selection>;
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A {
|
||||
void test() {
|
||||
String s = "Line1\nLine2";
|
||||
}
|
||||
}
|
||||
@@ -303,6 +303,7 @@ public class JoinLinesTest extends LightJavaCodeInsightTestCase {
|
||||
public void testJoinTextBlockAtStartLineNonEmpty() {doTest();}
|
||||
public void testJoinTextBlockAtStartLineFinalStep() {doTest();}
|
||||
public void testJoinTextBlockAtStartLineComplete() {doTest();}
|
||||
public void testJoinTextBlockAtStartLineComplete2() {doTest();}
|
||||
public void testJoinTextBlockAtStartLineCompleteWithEscapes() {doTest();}
|
||||
public void testJoinTextBlockBackSlash() {doTest();}
|
||||
public void testJoinTextBlockBackSlash2() {doTest();}
|
||||
|
||||
Reference in New Issue
Block a user