mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
text blocks: don't escape paste outside content of text block (IDEA-217353)
GitOrigin-RevId: 7ee24196154f11a34b50d2d95c62f374abe13f14
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3a73782bb6
commit
dca820c744
@@ -178,11 +178,14 @@ public class StringLiteralCopyPasteProcessor implements CopyPastePreProcessor {
|
||||
if (elementAtSelectionStart == null) {
|
||||
return null;
|
||||
}
|
||||
if (!isStringLiteral(elementAtSelectionStart) && !isCharLiteral(elementAtSelectionStart) && !isTextBlock(elementAtSelectionStart)) {
|
||||
final boolean isTextBlock = isTextBlock(elementAtSelectionStart);
|
||||
if (!isStringLiteral(elementAtSelectionStart) && !isCharLiteral(elementAtSelectionStart) && !isTextBlock) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (elementAtSelectionStart.getTextRange().getEndOffset() < selectionEnd) {
|
||||
final TextRange range = elementAtSelectionStart.getTextRange();
|
||||
final TextRange textRange = isTextBlock ? new TextRange(range.getStartOffset() + 3, range.getEndOffset() - 2) : range;
|
||||
if (textRange.getEndOffset() < selectionEnd) {
|
||||
final PsiElement elementAtSelectionEnd = file.findElementAt(selectionEnd);
|
||||
if (elementAtSelectionEnd == null) {
|
||||
return null;
|
||||
@@ -193,7 +196,6 @@ public class StringLiteralCopyPasteProcessor implements CopyPastePreProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
final TextRange textRange = elementAtSelectionStart.getTextRange();
|
||||
if (selectionStart <= textRange.getStartOffset() || selectionEnd >= textRange.getEndOffset()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
String empty = """
|
||||
"\"";
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
String empty = """
|
||||
"<caret>"";
|
||||
}
|
||||
@@ -26,6 +26,10 @@ class JavaTextBlocksHighlightingTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
doTestPaste("\"\"\"\ntarget\"\"\"".trimIndent())
|
||||
}
|
||||
|
||||
fun testNoEscapeWhenNotInTextBlockContent() {
|
||||
doTestPaste("\\");
|
||||
}
|
||||
|
||||
private fun doTestPaste(textToPaste: String) {
|
||||
myFixture.configureByText("plain.txt", "<selection>$textToPaste</selection>")
|
||||
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_COPY)
|
||||
|
||||
Reference in New Issue
Block a user