mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not anyhow change text pasted to a string literal
fixed PY-9566 pasting code on an indented line inserts that indentation at the end of the line
This commit is contained in:
@@ -61,6 +61,9 @@ public class PythonCopyPasteProcessor implements CopyPastePreProcessor {
|
||||
final int lineNumber = document.getLineNumber(caretOffset);
|
||||
final int lineStartOffset = getLineStartSafeOffset(document, lineNumber);
|
||||
|
||||
final PsiElement element = file.findElementAt(caretOffset);
|
||||
if (PsiTreeUtil.getParentOfType(element, PyStringLiteralExpression.class) != null) return text;
|
||||
|
||||
text = addLeadingSpaces(text, NOT_INDENT_FILTER, indentSize, indentChar);
|
||||
int firstLineIndent = StringUtil.findFirst(text, NOT_INDENT_FILTER);
|
||||
final String indentText = getIndentText(file, document, caretOffset, lineNumber, firstLineIndent);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
if True:
|
||||
s = "foo"
|
||||
'foo'
|
||||
@@ -0,0 +1,3 @@
|
||||
if True:
|
||||
s = "foo"
|
||||
'<caret>'
|
||||
@@ -0,0 +1,2 @@
|
||||
if True:
|
||||
s = "<selection>foo</selection>"
|
||||
@@ -309,6 +309,10 @@ public class PyCopyPasteTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPasteToStringLiteral() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTestTabs() {
|
||||
final CommonCodeStyleSettings.IndentOptions indentOptions =
|
||||
CodeStyleSettingsManager.getSettings(myFixture.getProject()).getIndentOptions(PythonFileType.INSTANCE);
|
||||
|
||||
Reference in New Issue
Block a user