do not move caret to the line beginning in case of selection on paste

fixed PY-8693 Smart indent pasted lines deletes part of string if pasting Django ORM query
This commit is contained in:
Ekaterina Tuzova
2013-02-04 13:26:38 +04:00
parent 31c3b75e64
commit ef0c8408ea
5 changed files with 22 additions and 1 deletions

View File

@@ -58,7 +58,7 @@ public class PythonCopyPasteProcessor implements CopyPastePreProcessor {
final int line = document.getLineNumber(selectionModel.getSelectionStart());
final int lineOffset = getLineStartSafeOffset(document, line);
final PsiElement ws = file.findElementAt(lineOffset);
int offset = ws instanceof PsiWhiteSpace? ws.getTextRange().getEndOffset() : lineOffset;
int offset = ws instanceof PsiWhiteSpace? ws.getTextRange().getEndOffset() : caretOffset;
if (text.equals(selectionModel.getSelectedText())) return text;
caretModel.moveToOffset(offset);
selectionModel.setSelection(offset, selectionModel.getSelectionEnd());

View File

@@ -0,0 +1,7 @@
#two lines formatting is important
filter(Q(myfield=123),
Q(myanotherfield=321))
a = filter(Q(myfield=123),
Q(myanotherfield=321))

View File

@@ -0,0 +1,5 @@
#two lines formatting is important
filter(Q(myfield=123),
Q(myanotherfield=321))
a = <caret><selection>'select_me_with_quotes'</selection>

View File

@@ -0,0 +1,5 @@
#two lines formatting is important
<selection><caret>filter(Q(myfield=123),
Q(myanotherfield=321))</selection>
a = 'select_me_with_quotes'

View File

@@ -259,6 +259,10 @@ public class PyCopyPasteTest extends PyTestCase {
doTest();
}
public void testTwoIndentedLines() { //PY-8693
doTest();
}
private void doTest() {
String name = getTestName(false);