mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
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:
@@ -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());
|
||||
|
||||
7
python/testData/copyPaste/TwoIndentedLines.after.py
Normal file
7
python/testData/copyPaste/TwoIndentedLines.after.py
Normal 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))
|
||||
|
||||
5
python/testData/copyPaste/TwoIndentedLines.dst.py
Normal file
5
python/testData/copyPaste/TwoIndentedLines.dst.py
Normal 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>
|
||||
5
python/testData/copyPaste/TwoIndentedLines.src.py
Normal file
5
python/testData/copyPaste/TwoIndentedLines.src.py
Normal 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'
|
||||
@@ -259,6 +259,10 @@ public class PyCopyPasteTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTwoIndentedLines() { //PY-8693
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
String name = getTestName(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user