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:
Ekaterina Tuzova
2013-06-19 18:44:15 +04:00
parent e826946631
commit 35cd1bebe1
5 changed files with 15 additions and 0 deletions
@@ -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);